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 LinkedBag<ItemType>::getFrequencyOf(const ItemType& anEntry) const
6: {
7: int frequency = 0;
8: int counter = 0;
9: Node<ItemType>* curPtr = headPtr;
10: while ((curPtr != nullptr) && (counter < itemCount))
11: {
12: if (anEntry == curPtr->getItem())
13: {
14: frequency++;
15: } // end if
16:
17: counter++;
18: curPtr = curPtr->getNext();
19: } // end while
20:
21: return frequency;
22: } // end getFrequencyOf