1: /** Counts the number of times a given entry appears in this bag.
2: @param anEntry The entry to be counted.
3: @return The number of times anEntry appears in the bag. */
4: public int getFrequencyOf(T anEntry)
5: {
6: int frequency = 0;
7: int loopCounter = 0;
8: Node currentNode = firstNode;
9:
10: while ((loopCounter < numberOfEntries) && (currentNode != null))
11: {
12: if (anEntry.equals(currentNode.data))
13: {
14: frequency++;
15: } // end if
16:
17: loopCounter++;
18: currentNode = currentNode.next;
19: } // end while
20:
21: return frequency;
22: } // end getFrequencyOf