Package org.n52.janmayen
Class IntervalTree<K,V>
java.lang.Object
org.n52.janmayen.IntervalTree<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
IntervalMap<K,V>
Tree implementation of
IntervalMap.-
Field Summary
Fields inherited from interface org.n52.janmayen.IntervalMap
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newIntervalTreethat uses the natural order of the keys.IntervalTree(Comparator<? super K> comparator) Creates a newIntervalTree. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a new element to the interval treevoidAdds a new element to the interval treeGet the first value falling into the interval.Get all values falling into the specified interval.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.n52.janmayen.IntervalMap
get, getOrDefault, getOrDefault, search
-
Constructor Details
-
IntervalTree
Creates a newIntervalTree.- Parameters:
comparator- the comparator to compare keys
-
IntervalTree
public IntervalTree()Creates a newIntervalTreethat uses the natural order of the keys.
-
-
Method Details
-
add
Adds a new element to the interval tree- Parameters:
min- the lower bound of the intervalmax- the upper bound of the intervalvalue- the associated value- Throws:
IllegalArgumentException- ifmin>max
-
add
Adds a new element to the interval tree- Parameters:
key- the lower and upper bound of the intervalvalue- the associated value
-
search
Description copied from interface:IntervalMapGet all values falling into the specified interval.- Specified by:
searchin interfaceIntervalMap<K,V> - Parameters:
lower- the upper boundupper- the lower bound- Returns:
- the values
-
get
Description copied from interface:IntervalMapGet the first value falling into the interval.- Specified by:
getin interfaceIntervalMap<K,V> - Parameters:
lower- the lower boundupper- the upper bound- Returns:
- the value
-