|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.mhhe.clrs2e.BinarySearchTree.Node
Inner class for a node of a binary search tree. May be
extended in subclasses of BinarySearchTree
.
Field Summary | |
protected java.lang.Comparable |
data
The data stored in the node. |
protected BinarySearchTree.Node |
left
The node's left child. |
protected BinarySearchTree.Node |
parent
The node's parent. |
protected BinarySearchTree.Node |
right
The node's right child. |
Constructor Summary | |
BinarySearchTree.Node(java.lang.Comparable data)
Initializes a node with the data and makes other pointers nil. |
Method Summary | |
int |
compareTo(java.lang.Object o)
Compares this node to another node. |
java.lang.String |
toString()
Returns the data instance variable of this node
as a String . |
java.lang.String |
toString(int depth)
Returns a multiline String representation of
the subtree rooted at this node, representing the depth of
each node by two spaces per depth preceding the
String representation of the node. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.Comparable data
protected BinarySearchTree.Node parent
protected BinarySearchTree.Node left
protected BinarySearchTree.Node right
Constructor Detail |
public BinarySearchTree.Node(java.lang.Comparable data)
data
- Data to save in the node.Method Detail |
public int compareTo(java.lang.Object o)
data
instance variables of the
two nodes.
compareTo
in interface java.lang.Comparable
o
- The other node.
o
; 0 if this node equals o
; a
positive integer if this node is greater than
o
.
java.lang.ClassCastException
- if o
is not a
Node
.public java.lang.String toString()
data
instance variable of this node
as a String
.
toString
in class java.lang.Object
public java.lang.String toString(int depth)
String
representation of
the subtree rooted at this node, representing the depth of
each node by two spaces per depth preceding the
String
representation of the node.
depth
- Depth of this node.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |