Package net.cscott.jutil
Class IntervalTree
An
IntervalTree is a mutable collection
of IntervalTree.Intervals. IntervalTrees support
efficient lookup of overlapping elements.
Every element in an IntervalTree must be an
IntervalTree.Interval. Thus element lookup is done based upon
IntervalTree.Intervals, 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.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classImmutable record representing a closed interval [low,high] holding an objectobj.Nested classes/interfaces inherited from class net.cscott.jutil.RedBlackTree
RedBlackTree.RBNodeNested 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 TypeMethodDescriptionaddInterval(Object datum, int low, int high) Constructs a newIntervalTree.Intervali and adds i tothis.protected voidSpliceszout from this.protected voidInserts z into some appropriate position inthis.protected BinaryTree<IntervalTree.Interval>.NodeFactory method forBinaryTree<K>.Node.Returns someIntervalTree.Intervalinthiswhich overlaps the bounds defined by the argument intervali, ornullif no such interval exists.protected BinaryTree<IntervalTree.Interval>.NodeSets the left child of p.protected BinaryTree<IntervalTree.Interval>.NodeSets the parent of p.protected BinaryTree<IntervalTree.Interval>.NodeSets the right child of p.Methods inherited from class net.cscott.jutil.RedBlackTree
leftRotate, rbDeleteFixup, rightRotate, swapPositions
-
Constructor Details
-
IntervalTree
public IntervalTree()Constructs a new emptyIntervalTree.
-
-
Method Details
-
makeNode
Description copied from class:RedBlackTreeFactory 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 classRedBlackTree<IntervalTree.Interval>
-
setLeft
protected BinaryTree<IntervalTree.Interval>.Node setLeft(BinaryTree<IntervalTree.Interval>.Node p, BinaryTree<IntervalTree.Interval>.Node l) Description copied from class:BinaryTreeSets the left child of p. Modifies: this, p, l Effects: p.left_post = l. Returns: p.left_pre.- Overrides:
setLeftin classBinaryTree<IntervalTree.Interval>
-
setRight
protected BinaryTree<IntervalTree.Interval>.Node setRight(BinaryTree<IntervalTree.Interval>.Node p, BinaryTree<IntervalTree.Interval>.Node r) Description copied from class:BinaryTreeSets the right child of p. Modifies: this, p, r Effects: p.right_post = r. Returns: p.right_pre.- Overrides:
setRightin classBinaryTree<IntervalTree.Interval>
-
setParent
protected BinaryTree<IntervalTree.Interval>.Node setParent(BinaryTree<IntervalTree.Interval>.Node c, BinaryTree<IntervalTree.Interval>.Node p) Description copied from class:BinaryTreeSets the parent of p. Modifies: this, c, p Effects: c.parent_post = p. Returns: c.parent_pre.- Overrides:
setParentin classBinaryTree<IntervalTree.Interval>
-
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 classRedBlackTree<IntervalTree.Interval>
-
deleteNode
Description copied from class:BinaryTreeSpliceszout from this. Based on CLR, pg 253. modifies: this, z- Overrides:
deleteNodein classRedBlackTree<IntervalTree.Interval>
-
searchOverlapping
Returns someIntervalTree.Intervalinthiswhich overlaps the bounds defined by the argument intervali, ornullif no such interval exists.This operation is named "Interval-Search" in CLR
- See Also:
-
allOverlapping
-
addInterval
Constructs a newIntervalTree.Intervali and adds i tothis. Convenience method. Requires: high > low.datumcan be null.
-