/** * Returns the element at the specified position in this list. */ public int get(int index) { checkRange(index); return array[index]; }
/** * Replaces the element at the specified position in this list with the specified element. * * @param index the index of the element to change * @param element the value to be stored at the specified position * @return the value previously stored at the specified position */ public int set(int index, int element) { checkRange(index); int oldval = array[index]; array[index] = element; return oldval; }
/** * Removes from this list all of the elements whose index is between fromIndex, * inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). */ public void removeRange(int fromIndex, int toIndex) { checkRange(fromIndex); checkRange(toIndex); if (fromIndex >= toIndex) { return; } int numtomove = size - toIndex; if (numtomove > 0) { System.arraycopy(array, toIndex, array, fromIndex, numtomove); } size -= (toIndex - fromIndex); }
/** * 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 remove * @return the value of the element that was removed * @throws UnsupportedOperationException when this operation is not * supported * @throws IndexOutOfBoundsException if the specified index is out of range */ public int remove(int index) { checkRange(index); int oldval = array[index]; int numtomove = size - index - 1; if (numtomove > 0) { System.arraycopy(array, index + 1, array, index, numtomove); } size--; return oldval; } /**
/** * Returns the element at the specified position in this list. */ public int get(int index) { checkRange(index); return array[index]; }
/** * Replaces the element at the specified position in this list with the specified element. * * @param index the index of the element to change * @param element the value to be stored at the specified position * @return the value previously stored at the specified position */ public int set(int index, int element) { checkRange(index); int oldval = array[index]; array[index] = element; return oldval; }
/** * Removes from this list all of the elements whose index is between fromIndex, * inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index). */ public void removeRange(int fromIndex, int toIndex) { checkRange(fromIndex); checkRange(toIndex); if (fromIndex >= toIndex) { return; } int numtomove = size - toIndex; if (numtomove > 0) { System.arraycopy(array, toIndex, array, fromIndex, numtomove); } size -= (toIndex - fromIndex); }
/** * 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 remove * @return the value of the element that was removed * @throws UnsupportedOperationException when this operation is not * supported * @throws IndexOutOfBoundsException if the specified index is out of range */ public int remove(int index) { checkRange(index); int oldval = array[index]; int numtomove = size - index - 1; if (numtomove > 0) { System.arraycopy(array, index + 1, array, index, numtomove); } size--; return oldval; }