Heterogeneous Container BS_Tree class NAME BS_Tree - store data in a binary search tree FILES BS_Tree.java BST_Iterator.java BST_Node.java Comparison.java SYNOPSIS class BS_Tree; DESCRIPTION The BS_Tree container stores Object values in a binary search tree. The user can insert and delete values from the BS_Tree using the methods insert() and remove(). The container also offers iterators for access only and methods for finding a value in the container. The user of a BS_Tree needs to specify an object that is a subtype of Comparison and that can be used to compare two Objects stored in the BS_Tree. METHODS Special methods: public BS_Tree(Comparison cmp); default constructor; takes as parameter an object that knows how to compare two Objects. BST_Node next(BST_Node current); this is a class method used by BST_Iterator to find the next node that follows after current. Methods: public int size(); returns the size of the BS_Tree; public boolean empty(); returns true if size is 0; public void insert(Object value); inserts a new value in the BS_Tree. Duplicates are allowed. public boolean remove(Object value); removes a value from the tree. Returns true if value was found and removed, false if the value wasn't found. public BST_Iterator find(Object value); returns an iterator to the first element with the given value found in the BS_Tree. Returns an iterator for which atEnd() returns true if such element is not found. public BST_Iterator iterator(); returns an iterator to the first value in the BS_Tree. The iterator allows the user to move inorder over the values in the tree. Comments: Comparison is an abstract class that must be extended by the user in order to provide an adequate comparison operation between two Objects stored in the BS_Tree. It offers the following method: public int compare(Object val1, Object val2); this method is expected to compare val1 and val2 and return: - a negative value if val1 < val2 - a positive value if val1 > val2 - 0 if val1 == val2 BST_Iterator is a class that defines the following methods: public boolean atEnd(); returns true if iterator went past the last element of the container. public void next(); move the iterator to the next element in the container. public Object current(); returns the current element pointed by the iterator. EXAMPLES: See the files BS_Tree_int.java, BST_int_Iterator.java, Comparison_Integer.java, BS_Tree_String.java, BST_String_Iterator.java and Comparison_String.java for examples of how to create homogeneous BS_Tree's for holding integers and Strings. The files BST_int_Test.java, BST_String_Test.java contain examples of use for the homogeneous containers defined in BS_Tree_int.java and BS_Tree_String.java. BUGS No known bugs at this time. Laurentiu Cristofor Last Change: November 6th, 1998