java.lang.Object 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 |
---|
public BTNode()
public BTNode(BTNode left, BTNode right, java.lang.Object data, java.lang.Comparable key)
left
- the left childright
- the right childdata
- the datakey
- the keyMethod Detail |
---|
public BTNode getLeftChild()
public BTNode getRightChild()
public java.lang.Object getData()
public java.lang.Comparable getKey()
public void setLeftChild(BTNode node)
public void setRightChild(BTNode node)
public void setData(java.lang.Object data)
public void setKey(java.lang.Comparable key)
public boolean isLeaf()
public java.lang.String toString()
[key: data, leftChild, rightChild]Note that leftChild and rightChild would be recursively displayed.
toString
in class java.lang.Object