Package net.cscott.jutil
Class RedBlackTree<K>
java.lang.Object
net.cscott.jutil.BinaryTree<K>
net.cscott.jutil.RedBlackTree<K>
- Type Parameters:
K- the type of the elements in this tree
- Direct Known Subclasses:
IntervalTree
A
RedBlackTree is a BinaryTree that uses
red-black properties to maintain a balanced form.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classARedBlackTree<K>.RBNodeis an element of this tree.Nested classes/interfaces inherited from class net.cscott.jutil.BinaryTree
BinaryTree.Node -
Field Summary
Fields inherited from class net.cscott.jutil.BinaryTree
comp, NIL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddeleteNode(BinaryTree<K>.Node z) Spliceszout from this.protected voidinsertNode(BinaryTree<K>.Node x) Inserts z into some appropriate position inthis.protected voidleftRotate(BinaryTree<K>.Node x) Pivots around the edge (x,x.right).protected BinaryTree<K>.NodeFactory method forBinaryTree<K>.Node.protected voidrbDeleteFixup(BinaryTree<K>.Node x) Post delete fixup routine.protected voidrightRotate(BinaryTree<K>.Node x) Pivots around the edge (x,x.left).protected voidswapPositions(BinaryTree<K>.Node a, BinaryTree<K>.Node b) Switches the positions ofaandbwithinthis.
-
Constructor Details
-
RedBlackTree
public RedBlackTree() -
RedBlackTree
-
-
Method Details
-
makeNode
Factory method forBinaryTree<K>.Node. Every construction of aBinaryTree<K>.Nodetakes place through this method; thus subclasses ofRedBlackTreecan associate new data with their own nodes by extending theBinaryTree<K>.Nodeclass and overriding this method.- Overrides:
makeNodein classBinaryTree<K>
-
insertNode
Description copied from class:BinaryTreeInserts z into some appropriate position inthis. requires: (z.left == z.right == NIL) modifies: this, z From CLR, pg 251.- Overrides:
insertNodein classBinaryTree<K>
-
swapPositions
Description copied from class:BinaryTreeSwitches the positions ofaandbwithinthis. Both must be in the tree; one may be the other's parent. Subclasses are expected to swap any data derived from the positions as well.- Overrides:
swapPositionsin classBinaryTree<K>
-
deleteNode
Description copied from class:BinaryTreeSpliceszout from this. Based on CLR, pg 253. modifies: this, z- Overrides:
deleteNodein classBinaryTree<K>
-
rbDeleteFixup
Post delete fixup routine.- See Also:
-
leftRotate
Pivots around the edge (x,x.right). Assumes x.right != null. -
rightRotate
Pivots around the edge (x,x.left). Assumes x.left != NIL.
-