|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.cscott.jutil.BinaryTree net.cscott.jutil.RedBlackTree net.cscott.jutil.IntervalTree
public class IntervalTree
An IntervalTree
is a mutable collection
of IntervalTree.Interval
s. IntervalTree
s support
efficient lookup of overlapping elements.
Every element in an IntervalTree
must be an
IntervalTree.Interval
. Thus element lookup is done based upon
IntervalTree.Interval
s, not on the datum assocatied with each
IntervalTree.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/interfaces inherited from class net.cscott.jutil.RedBlackTree |
---|
RedBlackTree.RBNode |
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 | |
---|---|
IntervalTree()
Constructs a new empty IntervalTree . |
Method Summary | |
---|---|
IntervalTree.Interval |
addInterval(Object datum,
int low,
int high)
Constructs a new IntervalTree.Interval i and adds
i to this . |
Iterator |
allOverlapping(IntervalTree.Interval i)
Returns an Iterator over IntervalTree.Interval s that
yields every interval in this that overlaps i . |
static void |
main(String[] args)
|
protected BinaryTree.Node |
makeNode(Object o)
requires: o is-a IntervalTree.Interval . |
IntervalTree.Interval |
searchOverlapping(IntervalTree.Interval i)
Returns some IntervalTree.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 net.cscott.jutil.RedBlackTree |
---|
deleteNode, insertNode, leftRotate, rbDeleteFixup, rightRotate, swapPositions |
Methods inherited from class net.cscott.jutil.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)
IntervalTree.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)
IntervalTree.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 IntervalTree.Interval
s that
yields every interval in this that overlaps i
.
public IntervalTree.Interval addInterval(Object datum, int low, int high)
IntervalTree.Interval
i and adds
i to this
.
Convenience method.
Requires: high > low.
datum
can be null.
public static void main(String[] args)
|
JUtil | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |