Interface SearchTree<T extends java.lang.Comparable<? super T>>

All Superinterfaces:
java.lang.Iterable<T>

public interface SearchTree<T extends java.lang.Comparable<? super T>>
extends java.lang.Iterable<T>

Interface for the Search Tree ADT.


Method Summary
 void add(T item)
          Adds the given item to the tree.
 void clear()
          Removes all items from the tree.
 boolean contains(T item)
          Checks whether the given item is in the tree.
 int height()
          Returns the height of the tree.
 List<T> inOrderTraversal()
          Returns a list of all the items in this search tree in order.
 boolean isEmpty()
          Returns whether the tree is empty.
 java.util.Iterator<T> iterator()
          Returns an iterator over the in-order traversal of the tree.
 List<T> postOrderTraversal()
          Returns a List of all the items in the tree, ordered as in a prost-order traversal.
 List<T> preOrderTraversal()
          Returns a List of all the items in the tree, ordered as in a pre-order traversal.
 void remove(T item)
          Removes the given item from the tree.
 int size()
          Returns the number of items in the tree.
 

Method Detail

contains

boolean contains(T item)
Checks whether the given item is in the tree.

Parameters:
item - The item to look for.
Returns:
true if that item is in the tree.

add

void add(T item)
Adds the given item to the tree.

Parameters:
item - The item to add.

remove

void remove(T item)
Removes the given item from the tree.

Parameters:
item - The item to add.

height

int height()
Returns the height of the tree.


size

int size()
Returns the number of items in the tree.


clear

void clear()
Removes all items from the tree.


isEmpty

boolean isEmpty()
Returns whether the tree is empty.


inOrderTraversal

List<T> inOrderTraversal()
Returns a list of all the items in this search tree in order.


iterator

java.util.Iterator<T> iterator()
Returns an iterator over the in-order traversal of the tree.

Specified by:
iterator in interface java.lang.Iterable<T extends java.lang.Comparable<? super T>>

preOrderTraversal

List<T> preOrderTraversal()
Returns a List of all the items in the tree, ordered as in a pre-order traversal.


postOrderTraversal

List<T> postOrderTraversal()
Returns a List of all the items in the tree, ordered as in a prost-order traversal.