public class RedBlackNode
extends java.lang.Object
Constructor and Description |
---|
RedBlackNode(java.lang.String data,
int color,
RedBlackNode p,
RedBlackNode lc,
RedBlackNode rc)
Construct a RedBlackNode with data, color, parent pointer, left child pointer
and right child pointer.
|
Modifier and Type | Method and Description |
---|---|
int |
getColor()
The getColor() method returns RED or BLACK.
|
java.lang.String |
getData()
The getData() method returns the data in the node.
|
RedBlackNode |
getLc()
The getLc() method returns the left child of the RedBlackNode.
|
RedBlackNode |
getP()
The getP() method returns the parent of the RedBlackNode.
|
RedBlackNode |
getRc()
The getRc() method returns the right child of the RedBlackNode.
|
void |
setColor(int color)
The setColor() method sets the color of the RedBlackNode.
|
void |
setData(java.lang.String data)
The setData() method sets the data or key of the RedBlackNode.
|
void |
setLc(RedBlackNode lc)
The setLc() method sets the left child of the RedBlackNode.
|
void |
setP(RedBlackNode p)
The setP() method sets the parent of the RedBlackNode.
|
void |
setRc(RedBlackNode rc)
The setRc() method sets the right child of the RedBlackNode.
|
java.lang.String |
toString()
The toString() methods returns a string representation of the
RedBlackNode.
|
public static final int RED
public static final int BLACK
public RedBlackNode(java.lang.String data, int color, RedBlackNode p, RedBlackNode lc, RedBlackNode rc)
data
- a simple value held in the treecolor
- either RED or BLACKp
- the parent pointerlc
- the pointer to the left child (will be null only for the node
that represents all external nulls.rc
- the pointer to the right child (will be null only for the
node that represents all external nulls.public java.lang.String toString()
toString
in class java.lang.Object
public int getColor()
public java.lang.String getData()
public RedBlackNode getLc()
public RedBlackNode getP()
public RedBlackNode getRc()
public void setColor(int color)
color
- is either RED or BLACKpublic void setData(java.lang.String data)
data
- is an int holding a node's data valuepublic void setLc(RedBlackNode lc)
lc
- establishes a left child for this nodepublic void setP(RedBlackNode p)
p
- establishes a parent pointer for this nodepublic void setRc(RedBlackNode rc)
rc
- establishes a right child for this node.