/** * Returns the element at the specified position in this list. * * @param index index of element to return. * @return the element at the specified position in this list. * @throws IndexOutOfBoundsException if index is out of range <tt>(index * < 0 || index >= size())</tt>. */ @Override public Long get(int index) { RangeCheck(index); return elementData[index]; }
/** * Returns the element at the specified position in this list. * * @param index index of element to return. * @return the element at the specified position in this list. * @throws IndexOutOfBoundsException if index is out of range <tt>(index * < 0 || index >= size())</tt>. */ @Override public long getLong(int index) { RangeCheck(index); return elementData[index]; }
/** * Replaces the element at the specified position in this list with * the specified element. * * @param index index of element to replace. * @param element element to be stored at the specified position. * @return the element previously at the specified position. * @throws IndexOutOfBoundsException if index out of range * <tt>(index < 0 || index >= size())</tt>. */ @Override public long set(int index, long element) { RangeCheck(index); long oldValue = elementData[index]; elementData[index] = element; return oldValue; }
/** * Removes the element at the specified position in this list. * Shifts any subsequent elements to the left (subtracts one from their * indices). * * @param index the index of the element to removed. * @return the element that was removed from the list. * @throws IndexOutOfBoundsException if index out of range <tt>(index * < 0 || index >= size())</tt>. */ @Override public long removeAtIndex(int index) { RangeCheck(index); modCount++; long oldValue = elementData[index]; int numMoved = size - index - 1; if (numMoved > 0) System.arraycopy(elementData, index+1, elementData, index, numMoved); elementData[--size] = 0; // Let gc do its work return oldValue; }