uk.ac.sanger.psu.gfmerge.util.algotools._old
Class RBTree

java.lang.Object
  |
  +--uk.ac.sanger.psu.gfmerge.util.algotools._old.RBTree

public class RBTree
extends java.lang.Object

A Red-Black tree

See Also:

Constructor Summary
RBTree()
          Constructs an empty Red-Black tree
 
Method Summary
 void ClearTree()
          Clear the tree of all nodes
 void drawRBTree(java.awt.Graphics g, int width, int height)
          Draws the Red-Black tree to the screen Calls DrawNode on the root, which then recalls that method many times - one for each nodein the tree.
 boolean isEmpty()
          Is tree empty?
 RBNode RBDoubleRotateLeft(RBNode current)
          The current node is made the left child of the right child, the right child is made the right child of its own left child, which in turn is made the current node.
 int RBInsert(long value)
          Insert a new Node with the specified value making sure that the Red-Black properties are preserved If the root node is null then this method inserts it, otherwise it calls the RecursiveInsert method to traverse the tree looking for the insertion point
 void setStatus(int status)
          Sets the current status of the tree
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RBTree

public RBTree()
Constructs an empty Red-Black tree

Method Detail

ClearTree

public void ClearTree()
Clear the tree of all nodes


setStatus

public void setStatus(int status)
Sets the current status of the tree


RBInsert

public int RBInsert(long value)
Insert a new Node with the specified value making sure that the Red-Black properties are preserved If the root node is null then this method inserts it, otherwise it calls the RecursiveInsert method to traverse the tree looking for the insertion point

Parameters:
value - The value of the node to be inserted
Returns:
0 indicates failure, 1 indicates success

RBDoubleRotateLeft

public RBNode RBDoubleRotateLeft(RBNode current)
The current node is made the left child of the right child, the right child is made the right child of its own left child, which in turn is made the current node. What was previously the current node is now red, and what was previously the right child's left child is now black. The tree's status set to RB_OK to indicate that the tree's RB properties have been met.

Parameters:
current - The current node
Returns:
The node where the rotate occurred

isEmpty

public boolean isEmpty()
Is tree empty?

Returns:
True if the tree is empty, else false.

drawRBTree

public void drawRBTree(java.awt.Graphics g,
                       int width,
                       int height)
Draws the Red-Black tree to the screen Calls DrawNode on the root, which then recalls that method many times - one for each nodein the tree.

Parameters:
g - The Graphics object
width - The Applet's width
height - The Applet's height