|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--harpoon.Util.Collections.BinaryTree | +--harpoon.Util.Collections.RedBlackTree | +--harpoon.Util.Collections.IntervalTree
An IntervalTree
is a mutable collection
of Interval
s. IntervalTree
s support
efficient lookup of overlapping elements.
Every element in an IntervalTree
must be an
Interval
. Thus element lookup is done based upon
Interval
s, not on the datum assocatied with each
Interval
.
The intervals maintained by this structure are considered to be closed intervals.
To make use of an IntervalTree
cleaner, a
convenience method, addInterval
is provided.
addInterval(java.lang.Object, int, int)
,
"CLR section 15.3, (page 290)."Nested Class Summary | |
static class |
IntervalTree.Interval
Immutable record representing a closed interval [ low ,high ] holding an object
obj . |
Nested classes inherited from class harpoon.Util.Collections.RedBlackTree |
RedBlackTree.RBNode |
Nested classes inherited from class harpoon.Util.Collections.BinaryTree |
BinaryTree.Node |
Field Summary |
Fields inherited from class harpoon.Util.Collections.BinaryTree |
comp, NIL |
Constructor Summary | |
IntervalTree()
Constructs a new empty IntervalTree . |
Method Summary | |
IntervalTree.Interval |
addInterval(Object datum,
int low,
int high)
Constructs a new Interval i and adds
i to this . |
Iterator |
allOverlapping(IntervalTree.Interval i)
Returns an Iterator over Intervals that
yields every interval in this that overlaps i . |
static void |
main(String[] args)
|
protected BinaryTree.Node |
makeNode(Object o)
requires: o is-a Interval . |
IntervalTree.Interval |
searchOverlapping(IntervalTree.Interval i)
Returns some Interval in this which
overlaps the bounds defined by the argument interval
i , or null if no such interval
exists. |
protected BinaryTree.Node |
setLeft(BinaryTree.Node p,
BinaryTree.Node l)
Sets the left child of p. |
protected BinaryTree.Node |
setParent(BinaryTree.Node c,
BinaryTree.Node p)
Sets the parent of p. |
protected BinaryTree.Node |
setRight(BinaryTree.Node p,
BinaryTree.Node r)
Sets the right child of p. |
Methods inherited from class harpoon.Util.Collections.RedBlackTree |
deleteNode, insertNode, leftRotate, rbDeleteFixup, rightRotate, swapPositions |
Methods inherited from class harpoon.Util.Collections.BinaryTree |
add, contains, dump, dump, maximum, maximum, minimum, minimum, remove, root, search, setRoot, successor, test |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public IntervalTree()
IntervalTree
.
Method Detail |
protected BinaryTree.Node makeNode(Object o)
Interval
.
makeNode
in class RedBlackTree
protected BinaryTree.Node setLeft(BinaryTree.Node p, BinaryTree.Node l)
BinaryTree
setLeft
in class BinaryTree
protected BinaryTree.Node setRight(BinaryTree.Node p, BinaryTree.Node r)
BinaryTree
setRight
in class BinaryTree
protected BinaryTree.Node setParent(BinaryTree.Node c, BinaryTree.Node p)
BinaryTree
setParent
in class BinaryTree
public IntervalTree.Interval searchOverlapping(IntervalTree.Interval i)
Interval
in this
which
overlaps the bounds defined by the argument interval
i
, or null
if no such interval
exists.
This operation is named "Interval-Search" in CLR
public Iterator allOverlapping(IntervalTree.Interval i)
Iterator
over Intervals
that
yields every interval in this that overlaps i
.
public IntervalTree.Interval addInterval(Object datum, int low, int high)
Interval
i and adds
i to this
.
Convenience method.
Requires: high > low.
datum
can be null.
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |