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 4.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 entry An object to be found. 15: @return True if the object was found in the tree. */ 16: public boolean contains(T entry); 17: 18: /** Retrieves a specific entry in this tree. 19: @param entry 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 entry); 23: 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 newEntry An object to be added to the tree. 28: @return Either null if newEntry was not in the tree already, or 29: the existing entry that matched the parameter newEntry 30: and has been replaced in the tree. */ 31: public T add(T newEntry); 32: 33: /** Removes a specific entry from this tree. 34: @param entry 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 entry); 38: 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