public class RedBlackTree extends BinaryTree
RedBlackTree is a BinaryTree that uses
red-black properties to maintain a balanced form.| Modifier and Type | Class and Description |
|---|---|
protected class |
RedBlackTree.RBNode
A
RedBlackTree.RBNode is an element of this tree. |
BinaryTree.Nodecomp, NIL| Constructor and Description |
|---|
RedBlackTree() |
RedBlackTree(java.util.Comparator c) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
deleteNode(BinaryTree.Node z)
Splices
z out from this. |
protected void |
insertNode(BinaryTree.Node x)
Inserts z into some appropriate position in
this. |
protected void |
leftRotate(BinaryTree.Node x)
Pivots around the edge (x,x.right).
|
static void |
main(java.lang.String[] args) |
protected BinaryTree.Node |
makeNode(java.lang.Object o)
Factory method for
Node. |
protected void |
rbDeleteFixup(BinaryTree.Node x)
Post delete fixup routine.
|
protected void |
rightRotate(BinaryTree.Node x)
Pivots around the edge (x,x.left).
|
protected void |
swapPositions(BinaryTree.Node a,
BinaryTree.Node b)
Switches the positions of
a and b
within this. |
public RedBlackTree()
public RedBlackTree(java.util.Comparator c)
protected BinaryTree.Node makeNode(java.lang.Object o)
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.makeNode in class BinaryTreeprotected void insertNode(BinaryTree.Node x)
BinaryTreethis.
requires: (z.left == z.right == NIL)
modifies: this, z
From CLR, pg 251.insertNode in class BinaryTreeprotected void swapPositions(BinaryTree.Node a, BinaryTree.Node b)
BinaryTreea and b
within this. Subclasses are expected to swap any
data derived from the positions as well.swapPositions in class BinaryTreeprotected void deleteNode(BinaryTree.Node z)
BinaryTreez out from this.
Based on CLR, pg 253.
modifies: this, zdeleteNode in class BinaryTreeprotected void rbDeleteFixup(BinaryTree.Node x)
protected void leftRotate(BinaryTree.Node x)
protected void rightRotate(BinaryTree.Node x)
public static void main(java.lang.String[] args)
Copyright (c) 2006 C. Scott Ananian