1: // @author Frank M. Carrano, Timothy M. Henry 2: // @version 5.0 3: public T remove(int givenPosition) 4: { 5: checkIntegrity(); 6: if ((givenPosition >= 1) && (givenPosition <= numberOfEntries)) 7: { 8: // Assertion: The list is not empty 9: T result = list[givenPosition]; // Get entry to be removed 10: // Move subsequent entries towards entry to be removed, 11: // unless it is last in list 12: if (givenPosition < numberOfEntries) 13: removeGap(givenPosition); 14: list[numberOfEntries] = null; 15: numberOfEntries--; 16: return result; // Return reference to removed entry 17: } 18: else 19: throw new IndexOutOfBoundsException( 20: "Illegal position given to remove operation."); 21: } // end remove