1: // Locates a given entry within the array bag. 2: // Returns the index of the entry, if located, or -1 otherwise. 3: // Precondition: checkInitialization has been called. 4: private int getIndexOf(T anEntry) 5: { 6: int where = -1; 7: boolean found = false; 8: int index = 0; 9: 10: while (!found && (index < numberOfEntries)) 11: { 12: if (anEntry.equals(bag[index])) 13: { 14: found = true; 15: where = index; 16: } // end if 17: index++; 18: } // end while 19: 20: // Assertion: If where > -1, anEntry is in the array bag, and it 21: // equals bag[where]; otherwise, anEntry is not in the array 22: 23: return where; 24: } // end getIndexOf