redblacktreeproject
Class RedBlackNode

java.lang.Object
  extended by redblacktreeproject.RedBlackNode

public class RedBlackNode
extends java.lang.Object


Field Summary
static int BLACK
           
static int RED
           
 
Constructor Summary
RedBlackNode(int data, int color, RedBlackNode p, RedBlackNode lc, RedBlackNode rc)
          Construct a RedBlackNode with data, color, parent pointer, left child pointer and right child pointer.
 
Method Summary
 int getColor()
          The getColor() method returns RED or BLACK.
 int 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(int 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RED

public static final int RED
See Also:
Constant Field Values

BLACK

public static final int BLACK
See Also:
Constant Field Values
Constructor Detail

RedBlackNode

public RedBlackNode(int data,
                    int color,
                    RedBlackNode p,
                    RedBlackNode lc,
                    RedBlackNode rc)
Construct a RedBlackNode with data, color, parent pointer, left child pointer and right child pointer.

Parameters:
data - a simple value held in the tree
color - either RED or BLACK
p - the parent pointer
lc - 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.
Method Detail

toString

public java.lang.String toString()
The toString() methods returns a string representation of the RedBlackNode.

Overrides:
toString in class java.lang.Object
Returns:
the string representation of a RedBlackNode

getColor

public int getColor()
The getColor() method returns RED or BLACK.

Returns:
the color value (RED or BLACK)

getData

public int getData()
The getData() method returns the data in the node.

Returns:
the data value in the node

getLc

public RedBlackNode getLc()
The getLc() method returns the left child of the RedBlackNode.

Returns:
the left child field

getP

public RedBlackNode getP()
The getP() method returns the parent of the RedBlackNode.

Returns:
the parent field

getRc

public RedBlackNode getRc()
The getRc() method returns the right child of the RedBlackNode.

Returns:
the right child field

setColor

public void setColor(int color)
The setColor() method sets the color of the RedBlackNode.

Parameters:
color - is either RED or BLACK

setData

public void setData(int data)
The setData() method sets the data or key of the RedBlackNode.

Parameters:
data - is an int holding a node's data value

setLc

public void setLc(RedBlackNode lc)
The setLc() method sets the left child of the RedBlackNode.

Parameters:
lc - establishes a left child for this node

setP

public void setP(RedBlackNode p)
The setP() method sets the parent of the RedBlackNode.

Parameters:
p - establishes a parent pointer for this node

setRc

public void setRc(RedBlackNode rc)
The setRc() method sets the right child of the RedBlackNode.

Parameters:
rc - establishes a right child for this node.