Newer
Older
// An abstract data type that represents a node in a Red Black Search Tree
public class Node<Key extends Comparable<Key>, Value>{
private Value val;
private Node<Key, Value> left, right;
/**
* Constructor
* @param key Used to assign order amongst the nodes/implement comparability
* @param val The value stored at a node
* @param n How many nodes are in the subtree beneath this node (inclusive)
* @param color True represents a red connection between the current node and its parent, black represents false
*/
public Node(Key key, Value val, int n, boolean color){
this.key = key;
this.val = val;
this.n = n;
this.color = color;
}
/**
* Getter for a node's key
* @return The node's key
*/
/**
* Getter for a node's value
* @return The node's value
*/
public Value val(){
/**
* Setter for a node's value
* @param val New value being assigned
*/
public void val(Value val){
/**
* Getter for a node's left child
* @return The node's left child
*/
public Node<Key, Value> left(){
/**
* Setter for a node's left child
* @param left The node's new left child
*/
public void left(Node<Key, Value> left){
/**
* Getter for a node's right child
* @return The node's right child
*/
public Node<Key, Value> right(){
/**
* Setter for a node's right child
* @param left The node's new right child
*/
public void right(Node<Key, Value> right){
/**
* Getter for the subtree size beneath the current node
* @return Subtree size
*/
/**
* Setter for a subtree's size
* @param n New subtree size
*/
/**
* Getter method for a node's color
* @return The node's color
*/
public boolean color(){
return this.color;
}
/**
* Setter for a node's color
* @param color New node color
*/
public void color(boolean color){
this.color = color;
}