Class BinarySearchTree.BSTNode

java.lang.Object
  extended byBinarySearchTree.BSTNode
All Implemented Interfaces:
java.lang.Cloneable
Enclosing class:
BinarySearchTree

protected static class BinarySearchTree.BSTNode
extends java.lang.Object
implements java.lang.Cloneable

Contains the data for each node in the BinarySearchTree as well as a set of functions that performs some important calculations on nodes to analyze and manipulate the tree structure. This class implements the cloneable interface. It does *not* attempt to clone the key and value members held in this node.


Field Summary
 java.lang.Object key
          Reference to the key this Node represents
 BinarySearchTree.BSTNode left
          Reference to the node that is considered the left child of this node in the tree structure.
 BinarySearchTree.BSTNode parent
          Reference to the node that is considered the parent of this node in the tree structure.
 BinarySearchTree.BSTNode right
          Reference to the node that is considered the right child of this node in the tree structure.
 java.lang.Object value
          Reference to the value this Node represents
 
Method Summary
 java.lang.Object clone()
          Copy the current instance into a new BSTNode.
 void print(java.io.PrintWriter writer, java.lang.String filler)
          Pretty-Print this node and its subtree.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

public java.lang.Object key
Reference to the key this Node represents


value

public java.lang.Object value
Reference to the value this Node represents


parent

public BinarySearchTree.BSTNode parent
Reference to the node that is considered the parent of this node in the tree structure.


left

public BinarySearchTree.BSTNode left
Reference to the node that is considered the left child of this node in the tree structure.


right

public BinarySearchTree.BSTNode right
Reference to the node that is considered the right child of this node in the tree structure.

Method Detail

print

public void print(java.io.PrintWriter writer,
                  java.lang.String filler)
Pretty-Print this node and its subtree.

Parameters:
writer - The PrintWriter to output the pretty printed tree to.
filler - The filler character to use while printing. (Usually and emptry string if you're calling this function from the outside).

clone

public java.lang.Object clone()
Copy the current instance into a new BSTNode. The cloned node will have no links to other nodes.

Returns:
The new copy of the current node.