csc241.samples.Set
Class Tree

java.lang.Object
  |
  +--csc241.samples.Set.Tree
All Implemented Interfaces:
Set

public class Tree
extends java.lang.Object
implements Set


Field Summary
protected  treeNode root_
           
protected  int size_
           
 
Constructor Summary
Tree()
          Construct an empty Binary Search Treee
 
Method Summary
 void add(java.lang.Comparable e)
          add an element to the Tree.
 void dump()
          The tree content is displayed in the form of a tree turned counterclockwise 90 degrees.
 java.lang.Comparable find(java.lang.Comparable e)
          find and return the element in the set or return null if the element is not in the set.
 void remove(java.lang.Comparable e)
          remove an element from the Tree; do nothing if element no in there.
e - the element to be removed
 int size()
          return the size of the set (i.e.
 java.lang.Comparable[] toArray()
          The toArray method creates and returns an array containing all elements in the tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

root_

protected treeNode root_

size_

protected int size_
Constructor Detail

Tree

public Tree()
Construct an empty Binary Search Treee
Method Detail

add

public void add(java.lang.Comparable e)
add an element to the Tree. Do nothing if element is already in the Set
e - the Comparable Object to be added
Specified by:
add in interface Set

remove

public void remove(java.lang.Comparable e)
remove an element from the Tree; do nothing if element no in there.
e - the element to be removed
Specified by:
remove in interface Set

find

public java.lang.Comparable find(java.lang.Comparable e)
find and return the element in the set or return null if the element is not in the set.
e - the element to be searched for
Specified by:
find in interface Set

size

public int size()
return the size of the set (i.e. the number of elements in the set).
Specified by:
size in interface Set

toArray

public java.lang.Comparable[] toArray()
The toArray method creates and returns an array containing all elements in the tree. In the case, the array will contain the objects in the ascending order.
Specified by:
toArray in interface Set

dump

public void dump()
The tree content is displayed in the form of a tree turned counterclockwise 90 degrees.
Specified by:
dump in interface Set