Package com.github.marschall.rangetree
Interface RangeMap<K extends Comparable<? super K>,V>
-
- Type Parameters:
K- the type of keys in this treeV- the type of values in this tree
- All Known Implementing Classes:
LLRBRangeTree,SynchronizedRangeMap
public interface RangeMap<K extends Comparable<? super K>,V>An object that maps ranges of keys to values. Cannot contain duplicate keys or overlapping ranges.The interface offers a subset of the operations of
Mapwith the write operations having instead two keys denoting the inclusive upper and lower bounds of a range.- See Also:
Map, Range tree
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclear()Removes all mappings from this object.VcomputeIfAbsent(K key, Function<? super K,Map.Entry<Range<? extends K>,? extends V>> mappingFunction)Looks up a value associated with a key.Vget(K key)Returns the value associated with a key.voidput(K low, K high, V value)Associates a range of keys with a value.VputIfAbsent(K low, K high, V value)Associates a range of keys with a value only if no existing mapping exists.
-
-
-
Method Detail
-
clear
void clear()
Removes all mappings from this object.- See Also:
Map.clear()
-
get
V get(K key)
Returns the value associated with a key.- Parameters:
key- the key for which to look up a value, notnull- Returns:
- the value associated with
keyornullif not found - Throws:
NullPointerException- ifkeyisnull- See Also:
Map.get(Object)
-
computeIfAbsent
V computeIfAbsent(K key, Function<? super K,Map.Entry<Range<? extends K>,? extends V>> mappingFunction)
Looks up a value associated with a key. If none is found the mapping function is applied. If the mapping produces a notnullvalue then the mapping is created.- Parameters:
key- the key for which to look up a value, notnullmappingFunction- the mapping function to apply if no value has been found, notnull- Returns:
- the value associated with
keyornullif not found - Throws:
NullPointerException- ifkeyisnullNullPointerException- ifkeyismappingFunction- See Also:
Map.computeIfAbsent(Object, Function),AbstractMap.SimpleImmutableEntry
-
put
void put(K low, K high, V value)
Associates a range of keys with a value.- Parameters:
low- the lower end of the range, inclusive, notnullhigh- the upper end of the range, inclusive, notnullvalue- the value to associate, possiblynull- Throws:
IllegalArgumentException- if a mapping for a part or the whole range already existsIllegalArgumentException- iflowis not less thanhighNullPointerException- ifloworhigharenull- See Also:
Map.put(Object, Object)
-
putIfAbsent
V putIfAbsent(K low, K high, V value)
Associates a range of keys with a value only if no existing mapping exists.- Parameters:
low- the lower end of the range, inclusive, notnullhigh- the upper end of the range, inclusive, notnullvalue- the value to associate, possiblynull- Returns:
- the value mapped to the key range before this method was called
- Throws:
IllegalArgumentException- iflowis not less thanhighNullPointerException- ifloworhigharenull- See Also:
Map.putIfAbsent(Object, Object)
-
-