All Packages Class Hierarchy This Package Previous Next Index
Interface DataStructures.SearchTree
- public abstract interface SearchTree
Protocol for search trees.
Note that all "matching" is based on the compares method.
-
find(Comparable)
- Find an item in the tree.
-
findMax()
- Find the largest item the tree.
-
findMin()
- Find the smallest item in the tree.
-
insert(Comparable)
- Insert into the tree.
-
isEmpty()
- Test if the tree is logically empty.
-
makeEmpty()
- Make the tree logically empty.
-
printTree()
- Print the tree contents in sorted order.
-
remove(Comparable)
- Remove from the tree.
-
removeMin()
- Remove the smallest item from the tree.
insert
public abstract void insert(Supporting.Comparable x) throws Exceptions.DuplicateItem
- Insert into the tree.
- Parameters:
- x - the item to insert.
- Throws: DuplicateItem
- if an item
that matches x is already in the tree.
remove
public abstract void remove(Supporting.Comparable x) throws Exceptions.ItemNotFound
- Remove from the tree.
- Parameters:
- x - the item to remove.
- Throws: ItemNotFound
- if no item
that matches x can be found in the tree.
removeMin
public abstract void removeMin() throws Exceptions.ItemNotFound
- Remove the smallest item from the tree.
- Throws: ItemNotFound
- if the tree is empty.
findMin
public abstract Supporting.Comparable findMin() throws Exceptions.ItemNotFound
- Find the smallest item in the tree.
- Returns:
- the smallest item.
- Throws: ItemNotFound
- if the tree is empty.
findMax
public abstract Supporting.Comparable findMax() throws Exceptions.ItemNotFound
- Find the largest item the tree.
- Returns:
- the largest item.
- Throws: ItemNotFound
- if the tree is empty.
find
public abstract Supporting.Comparable find(Supporting.Comparable x) throws Exceptions.ItemNotFound
- Find an item in the tree.
- Parameters:
- x - the item to search for.
- Returns:
- the matching item.
- Throws: ItemNotFound
- if no item
that matches x can be found in the tree.
makeEmpty
public abstract void makeEmpty()
- Make the tree logically empty.
isEmpty
public abstract boolean isEmpty()
- Test if the tree is logically empty.
- Returns:
- true if empty, false otherwise.
printTree
public abstract void printTree()
- Print the tree contents in sorted order.
All Packages Class Hierarchy This Package Previous Next Index