net.cscott.jutil

Class RedBlackTree

public class RedBlackTree extends BinaryTree

A RedBlackTree is a BinaryTree that uses red-black properties to maintain a balanced form.

See Also: "CLR section 14, (page 263)."

Nested Class Summary
protected classRedBlackTree.RBNode
A RBNode is an element of this tree.
Constructor Summary
RedBlackTree()
RedBlackTree(Comparator c)
Method Summary
protected voiddeleteNode(Node z)
protected voidinsertNode(Node x)
protected voidleftRotate(Node x)
Pivots around the edge (x,x.right).
static voidmain(String[] args)
protected NodemakeNode(Object o)
Factory method for Node.
protected voidrbDeleteFixup(Node x)
Post delete fixup routine.
protected voidrightRotate(Node x)
Pivots around the edge (x,x.left).
protected voidswapPositions(Node a, Node b)

Constructor Detail

RedBlackTree

public RedBlackTree()

RedBlackTree

public RedBlackTree(Comparator c)

Method Detail

deleteNode

protected void deleteNode(Node z)

insertNode

protected void insertNode(Node x)

leftRotate

protected void leftRotate(Node x)
Pivots around the edge (x,x.right). Assumes x.right != null.

main

public static void main(String[] args)

makeNode

protected Node makeNode(Object o)
Factory method for Node. Every construction of a Node takes place through this method; thus subclasses of RedBlackTree can associate new data with their own nodes by extending the Node class and overriding this method.

rbDeleteFixup

protected void rbDeleteFixup(Node x)
Post delete fixup routine.

See Also: "CLR, pg. 274"

rightRotate

protected void rightRotate(Node x)
Pivots around the edge (x,x.left). Assumes x.left != NIL.

swapPositions

protected void swapPositions(Node a, Node b)
Copyright © 2003 C. Scott Ananian