Source of 26.9.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0

  4: public T getEntry(T anEntry)
  5: {
  6:    return findEntry(getRootNode(), anEntry);
  7: } // end getEntry

  9: private T findEntry(BinaryNode<T> rootNode, T anEntry)
 10: {
 11:    T result = null;

 13:    if (rootNode != null)
 14:    {
 15:       T rootEntry = rootNode.getData();

 17:       if (anEntry.equals(rootEntry))
 18:          result = rootEntry;
 19:       else if (anEntry.compareTo(rootEntry) < 0)
 20:          result = findEntry(rootNode.getLeftChild(), anEntry);
 21:       else
 22:          result = findEntry(rootNode.getRightChild(), anEntry);
 23:    } // end if

 25:    return result;
 26: } // end findEntry