Exemplo n.º 1
0
 /**
  * Removes the element at the specified index, and returns it.
  *
  * @param index the position from which to remove the element
  * @return the object removed
  * @throws ArrayIndexOutOfBoundsException index < 0 || index >= size()
  * @since 1.2
  */
 public synchronized Object remove(int index) {
   checkBoundExclusive(index);
   Object temp = elementData[index];
   modCount++;
   elementCount--;
   if (index < elementCount)
     System.arraycopy(elementData, index + 1, elementData, index, elementCount - index);
   elementData[elementCount] = null;
   return temp;
 }
Exemplo n.º 2
0
 /**
  * Returns the Object stored at <code>index</code>.
  *
  * @param index the index of the Object to retrieve
  * @return the object at <code>index</code>
  * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
  * @see #get(int)
  */
 public synchronized Object elementAt(int index) {
   checkBoundExclusive(index);
   return elementData[index];
 }
Exemplo n.º 3
0
 /**
  * Puts <code>element</code> into the Vector at position <code>index</code> and returns the Object
  * that previously occupied that position.
  *
  * @param index the index within the Vector to place the Object
  * @param element the Object to store in the Vector
  * @return the previous object at the specified index
  * @throws ArrayIndexOutOfBoundsException index &lt; 0 || index &gt;= size()
  * @since 1.2
  */
 public synchronized Object set(int index, Object element) {
   checkBoundExclusive(index);
   Object temp = elementData[index];
   elementData[index] = element;
   return temp;
 }
Exemplo n.º 4
0
 /**
  * Returns the index of the first occurrence of <code>elem</code>, when searching backwards from
  * <code>index</code>. If the object does not occur in this Vector, or index is less than 0, -1 is
  * returned.
  *
  * @param e the object to search for
  * @param index the index to start searching in reverse from
  * @return the index of the Object if found, -1 otherwise
  * @throws IndexOutOfBoundsException if index &gt;= size()
  */
 public synchronized int lastIndexOf(Object e, int index) {
   checkBoundExclusive(index);
   for (int i = index; i >= 0; i--) if (equals(e, elementData[i])) return i;
   return -1;
 }