Class BTNode

java.lang.Object
  extended by BTNode

public class BTNode
extends java.lang.Object

Binary Tree Node


Constructor Summary
BTNode()
          Null-content constructor.
BTNode(BTNode left, BTNode right, java.lang.Object data, java.lang.Comparable key)
          Initializing constructor.
 
Method Summary
 java.lang.Object getData()
          Retrieves the data stored at this node.
 java.lang.Comparable getKey()
          Retrieves the key associated with this node.
 BTNode getLeftChild()
          Retrieves the left child of this node.
 BTNode getRightChild()
          Retrieves the right child of this node.
 boolean isLeaf()
          Determines if this is a leaf node.
 void setData(java.lang.Object data)
          Sets the data stored at this node.
 void setKey(java.lang.Comparable key)
          Sets the key associated with this node.
 void setLeftChild(BTNode node)
          Sets the left child of this node.
 void setRightChild(BTNode node)
          Sets the right child of this node.
 java.lang.String toString()
          Renders this node as a displayable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BTNode

public BTNode()
Null-content constructor.


BTNode

public BTNode(BTNode left,
              BTNode right,
              java.lang.Object data,
              java.lang.Comparable key)
Initializing constructor.

Parameters:
left - the left child
right - the right child
data - the data
key - the key
Method Detail

getLeftChild

public BTNode getLeftChild()
Retrieves the left child of this node.


getRightChild

public BTNode getRightChild()
Retrieves the right child of this node.


getData

public java.lang.Object getData()
Retrieves the data stored at this node.


getKey

public java.lang.Comparable getKey()
Retrieves the key associated with this node.


setLeftChild

public void setLeftChild(BTNode node)
Sets the left child of this node.


setRightChild

public void setRightChild(BTNode node)
Sets the right child of this node.


setData

public void setData(java.lang.Object data)
Sets the data stored at this node.


setKey

public void setKey(java.lang.Comparable key)
Sets the key associated with this node.


isLeaf

public boolean isLeaf()
Determines if this is a leaf node.

Returns:
true if this node is a leaf node, false otherwise

toString

public java.lang.String toString()
Renders this node as a displayable String. One option is to display a node as follows:
 [key: data, leftChild, rightChild]
 
Note that leftChild and rightChild would be recursively displayed.

Overrides:
toString in class java.lang.Object
Returns:
a displayable string representation