Class RedBlackNode<T extends Comparable<? super T>>
java.lang.Object
com.thomas.trees.BTNode<T>
com.thomas.trees.RedBlackNode<T>
- Type Parameters:
T- The type of the node
A simple implementation of a Red-Black Tree Node
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionRedBlackNode(T value) Creates a leaf nodeRedBlackNode(T value, RedBlackNode<T> l, RedBlackNode<T> r) Creates a node with childre -
Method Summary
Modifier and TypeMethodDescriptionGets the colour of the nodegetLeft()Gets the parent of this nodegetRight()booleanisBlack()Checks if the node is BLACKbooleanisRed()Checks if the node is REDvoidSet the colour of the nodevoidsetParent(RedBlackNode<T> parent) Set the colour of the node
-
Constructor Details
-
RedBlackNode
Creates a leaf node- Parameters:
value- The data value for this node- See Also:
-
RedBlackNode
Creates a node with childre- Parameters:
value- The data value for this nodel- The left subtreer- The right subtree- See Also:
-
-
Method Details
-
setColour
Set the colour of the node- Parameters:
colour- The new colour- See Also:
-
getColour
-
isRed
public boolean isRed()Checks if the node is RED- Returns:
- if the node is RED
- See Also:
-
isBlack
public boolean isBlack()Checks if the node is BLACK- Returns:
- if the node is BLACK
- See Also:
-
setParent
Set the colour of the node- Parameters:
parent- The new parent
-
getParent
-
getLeft
-
getRight
-