Source of 3.17.java


  1:    /** Tests whether this bag contains a given entry.
  2:        @param anEntry  The entry to locate.
  3:     @return  True if the bag contains anEntry, or false otherwise.
  4:     @author Frank M. Carrano, Timothy M. Henry
  5:     @version 5.0 */
  6:         public boolean contains(T anEntry)
  7:         {
  8:       boolean found = false;
  9:       Node currentNode = firstNode;
 10:       
 11:       while (!found && (currentNode != null))
 12:       {
 13:          if (anEntry.equals(currentNode.data))
 14:             found = true;
 15:          else
 16:             currentNode = currentNode.next;
 17:       } // end while
 18:       return found;
 19:    } // end contains