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>
public class IntervalTree<K,V> extends Object implements IntervalMap<K,V>
Tree implementation ofIntervalMap.
-
-
Field Summary
-
Fields inherited from interface org.n52.janmayen.IntervalMap
EMPTY
-
-
Constructor Summary
Constructors Constructor Description IntervalTree()Creates a newIntervalTreethat uses the natural order of the keys.IntervalTree(Comparator<? super K> comparator)Creates a newIntervalTree.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(K min, K max, V value)Adds a new element to the interval treevoidadd(K key, V value)Adds a new element to the interval treeOptional<V>get(K lower, K upper)Get the first value falling into the interval.Set<V>search(K lower, K upper)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, wait
-
Methods inherited from interface org.n52.janmayen.IntervalMap
get, getOrDefault, getOrDefault, search
-
-
-
-
Constructor Detail
-
IntervalTree
public IntervalTree(Comparator<? super K> comparator)
Creates a newIntervalTree.- Parameters:
comparator- the comparator to compare keys
-
IntervalTree
public IntervalTree()
Creates a newIntervalTreethat uses the natural order of the keys.
-
-
Method Detail
-
add
public void add(K min, K max, V value) throws IllegalArgumentException
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
public void add(K key, V value)
Adds a new element to the interval tree- Parameters:
key- the lower and upper bound of the intervalvalue- the associated value
-
search
public Set<V> search(K lower, K upper)
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
public Optional<V> get(K lower, K upper)
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
-
-