edu.ksu.cis.viewer
Class BinarySearchTree

java.lang.Object
  extended byedu.ksu.cis.viewer.BinarySearchTree
All Implemented Interfaces:
BSTInterface

public final class BinarySearchTree
extends Object
implements BSTInterface

An immutable binary search tree that can draw itself.

Author:
Rod Howell (howell@cis.ksu.edu)

Constructor Summary
BinarySearchTree()
          Constructs an empty BinarySearchTree.
 
Method Summary
 Object clone()
          Because this structure is immutable, this method simply returns this tree.
 JComponent getDrawing()
          Returns a drawing of this tree.
 JComponent getDrawing(Font fnt)
          Returns a drawing of this tree using the given Font.
 BSTInterface put(String key)
          Returns the BinarySearchTree resulting from the insertion of key into this BinarySearchTree.
 BSTInterface remove(String key)
          Returns the BinarySearchTree resulting from the removal of key from this BinarySearchTree.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinarySearchTree

public BinarySearchTree()
Constructs an empty BinarySearchTree.

Method Detail

put

public BSTInterface put(String key)
                 throws NullPointerException
Returns the BinarySearchTree resulting from the insertion of key into this BinarySearchTree. If key is already in this tree, an identical tree is returned.

Specified by:
put in interface BSTInterface
Throws:
NullPointerException - If key is null

remove

public BSTInterface remove(String key)
                    throws NullPointerException
Returns the BinarySearchTree resulting from the removal of key from this BinarySearchTree. If key is not in the tree, an identical tree is returned.

Specified by:
remove in interface BSTInterface
Throws:
NullPointerException - If key is null

getDrawing

public JComponent getDrawing()
Returns a drawing of this tree.

Specified by:
getDrawing in interface BSTInterface

getDrawing

public JComponent getDrawing(Font fnt)
                      throws NullPointerException
Returns a drawing of this tree using the given Font.

Specified by:
getDrawing in interface BSTInterface
Throws:
NullPointerException - if fnt is null.

clone

public Object clone()
Because this structure is immutable, this method simply returns this tree.

Specified by:
clone in interface BSTInterface