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: @author Frank M. Carrano, Timothy M. Henry
5: @version 5.0 */
6: public int getFrequencyOf(T anEntry)
7: {
8: int frequency = 0;
9: int loopCounter = 0;
10: Node currentNode = firstNode;
12: while ((loopCounter < numberOfEntries) && (currentNode != null))
13: {
14: if (anEntry.equals(currentNode.data))
15: {
16: frequency++;
17: } // end if
18:
19: loopCounter++;
20: currentNode = currentNode.next;
21: } // end while
23: return frequency;
24: } // end getFrequencyOf