/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param location * the index at which to put the specified object. * @param object * the object to add to this vector. * @return the previous element at the location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") @Override public synchronized E set(int location, E object) { if (location < elementCount) { E result = (E) elementData[location]; elementData[location] = object; return result; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Removes the element found at index position {@code location} from * this {@code Vector}. All elements with an index bigger than * {@code location} have their index decreased by 1. * * @param location * the index of the element to remove. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #removeElement * @see #removeAllElements * @see #size */ public synchronized void removeElementAt(int location) { if (location >= 0 && location < elementCount) { elementCount--; int size = elementCount - location; if (size > 0) { System.arraycopy(elementData, location + 1, elementData, location, size); } elementData[elementCount] = null; modCount++; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Removes the object at the specified location from this vector. All * elements with an index bigger than {@code location} have their index * decreased by 1. * * @param location * the index of the object to remove. * @return the removed object. * @throws IndexOutOfBoundsException * if {@code location < 0 || location >= size()}. */ @SuppressWarnings("unchecked") @Override public synchronized E remove(int location) { if (location < elementCount) { E result = (E) elementData[location]; elementCount--; int size = elementCount - location; if (size > 0) { System.arraycopy(elementData, location + 1, elementData, location, size); } elementData[elementCount] = null; modCount++; return result; } throw arrayIndexOutOfBoundsException(location, elementCount); }
throw arrayIndexOutOfBoundsException(location, elementCount);
modCount++; } else { throw arrayIndexOutOfBoundsException(location, elementCount);
return true; throw arrayIndexOutOfBoundsException(location, elementCount);
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Returns the element at the specified location in this vector. * * @param location * the index of the element to return in this vector. * @return the element at the specified location. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ @SuppressWarnings("unchecked") public synchronized E elementAt(int location) { if (location < elementCount) { return (E) elementData[location]; } throw arrayIndexOutOfBoundsException(location, elementCount); }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }
/** * Replaces the element at the specified location in this vector with the * specified object. * * @param object * the object to add to this vector. * @param location * the index at which to put the specified object. * @throws ArrayIndexOutOfBoundsException * if {@code location < 0 || location >= size()}. * @see #size */ public synchronized void setElementAt(E object, int location) { if (location < elementCount) { elementData[location] = object; } else { throw arrayIndexOutOfBoundsException(location, elementCount); } }