|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--com.mhhe.clrs2e.BinarySearchTree
|
+--com.mhhe.clrs2e.RedBlackTree
|
+--com.mhhe.clrs2e.OrderStatisticTree
Implements an order-statistic tree as described in Section 14.1 of Introduction to Algorithms, Second edition.
| Nested Class Summary | |
protected class |
OrderStatisticTree.Node
Inner class for an order-statistic tree node, extending a red-black tree node with an additional size field. |
static class |
OrderStatisticTree.SizeException
Exception thrown by actualSize() if the size of the
subtree does not agree with the size field of the subtree's
root node. |
| Nested classes inherited from class com.mhhe.clrs2e.RedBlackTree |
RedBlackTree.BlackHeightException |
| Nested classes inherited from class com.mhhe.clrs2e.BinarySearchTree |
BinarySearchTree.Visitor |
| Field Summary |
| Fields inherited from class com.mhhe.clrs2e.RedBlackTree |
BLACK, RED |
| Fields inherited from class com.mhhe.clrs2e.BinarySearchTree |
nil, root |
| Constructor Summary | |
OrderStatisticTree()
Creates an order-statistic tree with just a nil,
which is the root. |
|
| Method Summary | |
int |
actualSize()
Returns the actual size of the entire tree. |
int |
actualSize(java.lang.Object handle)
Returns the actual size of the subtree rooted at a node. |
void |
delete(java.lang.Object handle)
Deletes a node from the tree. |
java.lang.Object |
insert(java.lang.Comparable data)
Inserts data into the tree, creating a new node for this data. |
protected void |
leftRotate(RedBlackTree.Node x)
Calls RedBlackTree's RedBlackTree.leftRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the size fields. |
int |
rank(java.lang.Object handle)
Determines, for a given node, in which ordinal position the node would appear in an inorder walk of the tree. |
protected void |
rightRotate(RedBlackTree.Node x)
Calls RedBlackTree's RedBlackTree.rightRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the size fields. |
protected java.lang.Object |
select(BinarySearchTree.Node x,
int i)
Finds the node in a subtree that is at a given ordinal position in an inorder walk of the subtree. |
java.lang.Object |
select(int i)
Finds the node in the tree that is at a given ordinal position in an inorder walk of the tree. |
protected void |
setNil(OrderStatisticTree.Node node)
Set the sentinel nil to a given node. |
protected void |
treeInsert(OrderStatisticTree.Node z)
Inserts a node, updating the size fields of its
ancestors before the superclass's insertNode is
called. |
| Methods inherited from class com.mhhe.clrs2e.RedBlackTree |
blackHeight, blackHeight, deleteFixup, insertFixup, setNil, treeInsert |
| Methods inherited from class com.mhhe.clrs2e.BinarySearchTree |
dereference, inorderWalk, inorderWalk, isNil, iterativeSearch, maximum, minimum, postorderWalk, postorderWalk, predecessor, preorderWalk, preorderWalk, search, search, setNil, successor, toString, treeInsert, treeMaximum, treeMinimum |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public OrderStatisticTree()
nil,
which is the root.
| Method Detail |
protected void setNil(OrderStatisticTree.Node node)
nil to a given node.
node - The node that nil is set to.public java.lang.Object select(int i)
i - The ordinal position.
protected java.lang.Object select(BinarySearchTree.Node x,
int i)
x - Root of the subtree.i - The ordinal position.
public int rank(java.lang.Object handle)
handle - Handle to the node.
java.lang.ClassCastException - if Handle does not
reference a Node object.protected void leftRotate(RedBlackTree.Node x)
RedBlackTree's RedBlackTree.leftRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the size fields.
leftRotate in class RedBlackTreex - handle The node being left rotated.protected void rightRotate(RedBlackTree.Node x)
RedBlackTree's RedBlackTree.rightRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the size fields.
rightRotate in class RedBlackTreex - handle The node being right rotated.public java.lang.Object insert(java.lang.Comparable data)
insert in interface Dictionaryinsert in class RedBlackTreedata - The data being inserted.
Node that is created.
Node is opaque to methods outside this class.protected void treeInsert(OrderStatisticTree.Node z)
size fields of its
ancestors before the superclass's insertNode is
called.
z - The node to insert.public void delete(java.lang.Object handle)
delete in interface Dictionarydelete in class RedBlackTreehandle - Handle to the node being deleted.
java.lang.ClassCastException - if handle is not a
Node object.
public int actualSize()
throws OrderStatisticTree.SizeException
OrderStatisticTree.SizeException - if any size instance
variable is incorrect.
public int actualSize(java.lang.Object handle)
throws OrderStatisticTree.SizeException
handle - Handle to the node that is the root of the
subtree.
OrderStatisticTree.SizeException - if any size instance
variable is incorrect.
java.lang.ClassCastException - if handle is not a
Node object.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||