edu.ksu.cis.viewer
Class AATree

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

public final class AATree
extends Object
implements BSTInterface

An immutable AA tree that can draw itself. An AA tree is a binary search tree such that if it is nonempty, the level of a node is 1 if the node is a leaf, the node is red if it is the same level as its parent, and the node is black if it is one level less than the level of the parent.

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

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

Constructor Detail

AATree

public AATree()
Constructs an empty AA Tree.

Method Detail

put

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

Specified by:
put in interface BSTInterface
Throws:
NullPointerException - If keynull

remove

public BSTInterface remove(String key)
                    throws NullPointerException
Returns the AATree resulting from the removal of key from this AATree. 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 the tree.

Specified by:
getDrawing in interface BSTInterface

getDrawing

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

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

clone

public Object clone()
Returns a clone of this tree.

Specified by:
clone in interface BSTInterface
Returns:
a clone of this tree