Source of 13.11.java


  1: public T remove(int givenPosition)
  2: {
  3:    checkInitialization();
  4:    if ((givenPosition >= 1) && (givenPosition <= numberOfEntries))
  5:    {
  6:       assert !isEmpty();
  7:       T result = list[givenPosition]; // Get entry to be removed
  8:       // Move subsequent entries towards entry to be removed,
  9:       // unless it is last in list
 10:       if (givenPosition < numberOfEntries)
 11:          removeGap(givenPosition);
 12:       numberOfEntries--;
 13:       return result;
 14:    }
 15:    else
 16:       throw new IndexOutOfBoundsException(
 17:                 "Illegal position given to remove operation.");
 18: } // end remove
 19: // Version 4.0