T
- - the type of Interval this tree containspublic class IntervalTree<T extends Interval> extends Object implements Iterable<T>
The underlying data-structure is a red-black tree largely implemented from CLRS (Introduction to Algorithms, 2nd edition) with the interval-tree extensions mentioned in section 14.3
Constructor and Description |
---|
IntervalTree()
Constructs an empty IntervalTree.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(T t)
Whether or not this IntervalTree contains the given Interval.
|
boolean |
delete(T t)
Deletes the given value from this IntervalTree.
|
void |
forAllAbove(int ub,
Consumer<T> ex) |
void |
forAllBelow(int lb,
Consumer<T> ex) |
T |
get(int s,
int e)
Whether or not this IntervalTree contains the given Interval.
|
boolean |
insert(T t)
Inserts the given value into the IntervalTree.
|
boolean |
isEmpty()
Whether this IntervalTree is empty or not.
|
Iterator<T> |
iterator()
An Iterator which traverses the tree in ascending order.
|
Optional<T> |
maximum()
The maximum value in this IntervalTree
|
Optional<T> |
minimum()
The minimum value in this IntervalTree
|
Iterator<T> |
overlappers(int start,
int end)
An Iterator over the Intervals in this IntervalTree that overlap the given Interval
|
int |
size()
The number of intervals stored in this IntervalTree.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public boolean isEmpty()
public int size()
public boolean contains(T t)
t
- - the Interval to search forpublic T get(int s, int e)
s
- - the starting time of the Interval to search fore
- - the ending time of the Interval to search forpublic Optional<T> minimum()
public Optional<T> maximum()
public Iterator<T> overlappers(int start, int end)
start
- - the starting point of the overlapping Intervalend
- - the ending point of the overlapping Intervalpublic boolean insert(T t)
This method constructs a new Node containing the given value and places it into the tree. If the value already exists within the tree, the tree remains unchanged.
t
- - the value to place into the treepublic boolean delete(T t)
If the value does not exist, this IntervalTree remains unchanged.
t
- - the Interval to delete from the treeCopyright © 2018. All rights reserved.