TKey
- - type of the key. Must implement Comparable.TValue
- - type of the value to associate.public abstract class IntervalTree<TKey extends java.lang.Comparable<TKey>,TValue>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected class |
IntervalTree.EndPoint
Represents a single end point (open, close or both) of a range.
|
class |
IntervalTree.Entry
Represents a range and a value in this interval tree.
|
protected static class |
IntervalTree.State |
Modifier and Type | Field and Description |
---|---|
protected java.util.NavigableMap<TKey,IntervalTree.EndPoint> |
bounds |
Constructor and Description |
---|
IntervalTree() |
Modifier and Type | Method and Description |
---|---|
protected void |
addEndPoint(TKey key,
TValue value,
IntervalTree.State state) |
boolean |
containsKey(TKey key)
Determines if the given key is within an interval.
|
protected abstract TKey |
decrementKey(TKey key) |
java.util.Set<IntervalTree.Entry> |
entrySet()
Enumerates over every range in this interval tree.
|
TValue |
get(TKey key)
Retrieves the value of the range that matches the given key, or NULL if nothing was found.
|
protected IntervalTree.EndPoint |
getEndPoint(TKey key)
Get the end-point composite associated with this key.
|
protected abstract TKey |
incrementKey(TKey key) |
void |
put(TKey lowerBound,
TKey upperBound,
TValue value)
Associates a given interval of keys with a certain value.
|
void |
putAll(IntervalTree<TKey,TValue> other)
Inserts every range from the given tree into the current tree.
|
void |
remove(TKey lowerBound,
TKey upperBound)
Removes every interval that intersects with the given range.
|
protected void |
removeIfNonNull(java.lang.Object key) |
protected java.util.NavigableMap<TKey extends java.lang.Comparable<TKey>,IntervalTree.EndPoint> bounds
public void remove(TKey lowerBound, TKey upperBound)
lowerBound
- - lowest value to remove.upperBound
- - highest value to remove.protected void removeIfNonNull(java.lang.Object key)
protected void addEndPoint(TKey key, TValue value, IntervalTree.State state)
public void put(TKey lowerBound, TKey upperBound, TValue value)
Overlapping intervals are not permitted. A key can only be associated with a single value.
lowerBound
- - the minimum key (inclusive).upperBound
- - the maximum key (inclusive).value
- - the value, or NULL to reset this range.public boolean containsKey(TKey key)
key
- - key to check.public java.util.Set<IntervalTree.Entry> entrySet()
public void putAll(IntervalTree<TKey,TValue> other)
other
- - the other tree to read from.public TValue get(TKey key)
key
- - the level to read for.protected IntervalTree.EndPoint getEndPoint(TKey key)
key
- - key to search for.