| 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectTreeNode
Author: Clare So 
 Revised: March 15, 2007 
 
 Description: Specifies a node in a binary tree
 
 Features:
 
| Constructor Summary | |
TreeNode(java.lang.Comparable contents)
Constructor of TreeNode  | 
|
| Method Summary | |
 int | 
compareTo(java.lang.Object node)
Compare two objects of (probably) the same kind.  | 
 boolean | 
equals(java.lang.Object o)
Check if the current node is equal to the other node.  | 
 TreeNode | 
getLeft()
Get the left child  | 
 TreeNode | 
getRight()
Get the right child  | 
 boolean | 
haveLeft()
Test if the left child is not null  | 
 boolean | 
haveRight()
Test if the right child is not null  | 
 boolean | 
isGreaterThan(TreeNode node)
See if the current node is larger  | 
 boolean | 
isLeaf()
Test if the current node is a leaf  | 
 boolean | 
isLessThan(TreeNode node)
See if the current node is less  | 
 TreeNode | 
setLeft(TreeNode node)
Store the new node to the left of the current one only if the current node's left child is null.  | 
 TreeNode | 
setRight(TreeNode node)
Store the new node to the right of the current one only if the current node's right child is null.  | 
 java.lang.String | 
toString()
Create a string representation of the node  | 
| Methods inherited from class java.lang.Object | 
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait | 
| Constructor Detail | 
public TreeNode(java.lang.Comparable contents)
contents - Data to be stored in the node| Method Detail | 
public TreeNode setLeft(TreeNode node)
node - New node to be inserted
public TreeNode setRight(TreeNode node)
node - New node to be inserted
public TreeNode getLeft()
public TreeNode getRight()
public boolean haveRight()
public boolean haveLeft()
public boolean isLeaf()
public int compareTo(java.lang.Object node)
              throws java.lang.ClassCastException
compareTo in interface java.lang.Comparablenode - Object to be compared
java.lang.ClassCastExceptionpublic boolean isGreaterThan(TreeNode node)
node - the node to be compared
public boolean isLessThan(TreeNode node)
node - the node to be compared
public boolean equals(java.lang.Object o)
o - the node to be compared
public java.lang.String toString()
  | 
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||