Source of 2.20.java


  1: 
  2:         /** Counts the number of times a given entry appears in a bag.
  3:                  @param anEntry  The entry to be counted.
  4:                  @return  the number of times anEntry appears in the bag. */
  5:         public int getFrequencyOf(T anEntry) 
  6:         {
  7:       checkInitialization();
  8:                 int counter = 0;
  9: 
 10:                 for (int index = 0; index < numberOfEntries; index++) 
 11:                 {
 12:                         if (anEntry.equals(bag[index]))
 13:                         {
 14:                                 counter++;
 15:                         } // end if
 16:                 } // end for
 17: 
 18:                 return counter;
 19:         } // end getFrequencyOf
 20: