Source of SearchTreeInterface.java


  1: package TreePackage;
  2: import java.util.Iterator;
  3: /**
  4:    An interface for a search tree.
  5:    
  6:    @author Frank M. Carrano
  7:    @author Timothy M. Henry
  8:    @version 5.0
  9: */
 10: public interface SearchTreeInterface<T extends Comparable<? super T>> 
 11:        extends TreeInterface<T>
 12: {
 13:    /** Searches for a specific entry in this tree.
 14:        @param anEntry  An object to be found.
 15:        @return  True if the object was found in the tree. */
 16:    public boolean contains(T anEntry);

 18:    /** Retrieves a specific entry in this tree.
 19:        @param anEntry  An object to be found.
 20:        @return  Either the object that was found in the tree or
 21:                 null if no such object exists. */
 22:    public T getEntry(T anEntry);

 24:    /** Adds a new entry to this tree, if it does not match an existing 
 25:        object in the tree. Otherwise, replaces the existing object with
 26:        the new entry.
 27:        @param anEntry  An object to be added to the tree.
 28:        @return  Either null if anEntry was not in the tree but has been added, or
 29:                 the existing entry that matched the parameter anEntry
 30:                 and has been replaced in the tree. */
 31:    public T add(T anEntry);

 33:    /** Removes a specific entry from this tree.
 34:        @param anEntry  An object to be removed.
 35:        @return  Either the object that was removed from the tree or
 36:                 null if no such object exists. */
 37:    public T remove(T anEntry);

 39:    /** Creates an iterator that traverses all entries in this tree.
 40:        @return  An iterator that provides sequential and ordered access
 41:                 to the entries in the tree. */
 42:    public Iterator<T> getInorderIterator();
 43: } // end SearchTreeInterface