1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: template<class ItemType> 5: int SortedListIsA<ItemType>::getPosition(const ItemType& anEntry) const 6: { 7: int position = 1; 8: int length = LinkedList<ItemType>::getLength(); 9: 10: while ( (position <= length) && 11: (anEntry > LinkedList<ItemType>::getEntry(position)) ) 12: { 13: position++; 14: } // end while 15: 16: if ( (position > length) || 17: (anEntry != LinkedList<ItemType>::getEntry(position)) ) 18: { 19: position = –position; 20: } // end if 21: 22: return position; 23: } // end getPosition