public class DynamicIntervalTree<U extends Comparable<U>,T extends Interval<U>> extends Object
Insertion and deletion of intervals to and from this tree completes in time O(log(n)) where n is the number of intervals stored in the tree.
This tree consumes linear space in the number of intervals stored in the tree.
Note that this implementation supports all three closed, open and half-open intervals.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DynamicIntervalTree.Node<U extends Comparable<U>,T extends Interval<U>>
A node for a dynamic interval tree is a red-black tree node
augmented to store the maximum high endpoint among intervals stored
within the subtree rooted at the node.
|
| Modifier and Type | Field and Description |
|---|---|
RedBlackTree<T> |
binarySearchTree |
| Constructor and Description |
|---|
DynamicIntervalTree() |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Clear the contents of the tree.
|
boolean |
delete(T interval)
Delete the specified interval from this tree.
|
protected T |
fetchContainingInterval(U queryPoint)
Fetch an interval containing the specified point.
|
Collection<T> |
fetchContainingIntervals(U queryPoint)
Fetch intervals containing the specified point.
|
protected T |
fetchOverlappingInterval(T queryInterval)
Fetch an interval overlapping the specified interval.
|
Collection<T> |
fetchOverlappingIntervals(T queryInterval)
Fetch intervals overlapping the specified interval.
|
int |
getSize()
Get the number of intervals being stored in the tree.
|
boolean |
insert(T interval)
Insert the specified interval into this tree.
|
public RedBlackTree<T extends Interval<U>> binarySearchTree
public void clear()
public boolean delete(T interval)
interval - the interval to delete.protected T fetchContainingInterval(U queryPoint)
queryPoint - the query point.public Collection<T> fetchContainingIntervals(U queryPoint)
queryPoint - the query point.protected T fetchOverlappingInterval(T queryInterval)
queryInterval - the query interval.public Collection<T> fetchOverlappingIntervals(T queryInterval)
queryInterval - the query interval.public int getSize()
public boolean insert(T interval)
interval - the interval to insert.Copyright © 1994–2024 Peter Murray-Rust. All rights reserved.