1: @author Frank M. Carrano, Timothy M. Henry 2: @version 5.0 3: // Removes and returns the entry at a given index within the array bag. 4: // If no such entry exists, returns null. 5: // Preconditions: 0 <= givenIndex < numberOfEntries; 6: // checkIntegrity has been called. 7: private T removeEntry(int givenIndex) 8: { 9: T result = null; 10: 11: if (!isEmpty() && (givenIndex >= 0)) 12: { 13: result = bag[givenIndex]; // Entry to remove 14: bag[givenIndex] = bag[numberOfEntries - 1]; // Replace entry with last entry 15: bag[numberOfEntries - 1] = null; // Remove last entry 16: numberOfEntries--; 17: } // end if 18: 19: return result; 20: } // end removeEntry