|
|||||||||
| 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.IntervalTree
Implements an interval tree as described in Section 14.3 of Introduction to Algorithms, Second edition.
| Nested Class Summary | |
protected class |
IntervalTree.Node
Inner class for an interval tree node, extending a red-black tree node with an additional max field. |
| 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 | |
IntervalTree()
Creates an empty interval tree with just a nil,
which is the root. |
|
| Method Summary | |
void |
delete(java.lang.Object handle)
Deletes a node from the tree. |
java.lang.Object |
insert(java.lang.Comparable data)
Inserts an interval into the tree, creating a new node for this interval. |
protected void |
leftRotate(RedBlackTree.Node handle)
Calls RedBlackTree's RedBlackTree.leftRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the max fields. |
protected void |
rightRotate(RedBlackTree.Node handle)
Calls RedBlackTree's RedBlackTree.rightRotate(com.mhhe.clrs2e.RedBlackTree.Node) and then fixes the max
fields. |
java.lang.Object |
search(java.lang.Comparable k)
Finds an interval that overlaps with a given interval. |
protected void |
treeInsert(IntervalTree.Node x)
Inserts a node, updating the max 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, 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 IntervalTree()
nil,
which is the root.
| Method Detail |
protected void leftRotate(RedBlackTree.Node handle)
RedBlackTree's RedBlackTree.leftRotate(com.mhhe.clrs2e.RedBlackTree.Node)
and then fixes the max fields.
leftRotate in class RedBlackTreehandle - Handle to the node being left rotated.protected void rightRotate(RedBlackTree.Node handle)
RedBlackTree's RedBlackTree.rightRotate(com.mhhe.clrs2e.RedBlackTree.Node) and then fixes the max
fields.
rightRotate in class RedBlackTreehandle - Handle to the node being right rotated.public java.lang.Object insert(java.lang.Comparable data)
insert in interface Dictionaryinsert in class RedBlackTreedata - The interval being inserted.
Node that is created.
Node is opaque to methods outside this class.
java.lang.ClassCastException - if data is not an
Interval object.protected void treeInsert(IntervalTree.Node x)
max fields of its
ancestors before the superclass's insertNode is
called.
x - 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 java.lang.Object search(java.lang.Comparable k)
search in interface Dictionarysearch in class BinarySearchTreek - The interval to overlap with.
k,
or the sentinel nil if no interval in the tree
overlaps with k.
java.lang.ClassCastException - if k is not an
Interval object.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||