net.sf.beanlib.utils.range
Class RangeTreeMap<T,K extends RangeBoundable<T>,V>
java.lang.Object
net.sf.beanlib.utils.range.AbstractMap<K,V>
net.sf.beanlib.utils.range.ExtensibleTreeMap<K,V>
net.sf.beanlib.utils.range.RangeTreeMap<T,K,V>
- All Implemented Interfaces:
- Serializable, Cloneable, Map<K,V>, SortedMap<K,V>, SortedRangeMap<T,K,V>
public class RangeTreeMap<T,K extends RangeBoundable<T>,V>
- extends ExtensibleTreeMap<K,V>
- implements SortedRangeMap<T,K,V>
Range Tree Map that supports retrieval by using a point that falls within
the range of a key which implements RangeBoundable
.
- Author:
- Joe D. Velopar
- See Also:
- Serialized Form
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Methods inherited from class net.sf.beanlib.utils.range.ExtensibleTreeMap |
addAllForTreeSet, clear, clone, comparator, containsKey, containsValue, entrySet, firstKey, get, headMap, keySet, lastKey, put, putAll, readTreeSet, remove, size, subMap, tailMap, values |
Methods inherited from interface java.util.Map |
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
RangeTreeMap
public RangeTreeMap()
RangeTreeMap
public RangeTreeMap(Comparator<? super K> c)
RangeTreeMap
public RangeTreeMap(Map<? extends K,? extends V> m)
RangeTreeMap
public RangeTreeMap(SortedMap<K,? extends V> m)
RangeTreeMap
public RangeTreeMap(SortedRangeMap<T,K,? extends V> m)
getByPoint
public V getByPoint(Comparable<T> point)
- Description copied from interface:
SortedRangeMap
- Returns the value to which this map maps a key with a range
that the specified point falls within.
Returns null if the map contains no mapping for any key with such range.
A return value of null does not necessarily indicate that the
map contains no mapping for a key with such range; it's also possible that the map
explicitly maps the key with such range to null. The containsKeyPoint
operation may be used to distinguish these two cases.
- Specified by:
getByPoint
in interface SortedRangeMap<T,K extends RangeBoundable<T>,V>
- Parameters:
point
- the point that falls within the range of a key
whose associated value is to be returned.
- Returns:
- the value to which this map maps a key with a range
that the specified point falls within, or
null if the map contains no mapping for any key with such range.
- See Also:
SortedRangeMap.containsKeyPoint(Comparable)
getEntryByPoint
private ExtensibleTreeMap.NodeEntry<K,V> getEntryByPoint(Comparable<T> point)
containsKeyPoint
public boolean containsKeyPoint(Comparable<T> point)
- Description copied from interface:
SortedRangeMap
- Returns true if this map contains a mapping of a key
with a range that the specified point falls within.
- Specified by:
containsKeyPoint
in interface SortedRangeMap<T,K extends RangeBoundable<T>,V>
- Parameters:
point
- point to be tested.
- Returns:
- true if this map contains a mapping of a key with a range
that the specified point falls within.
comparePointToRange
private int comparePointToRange(Comparable<T> point,
RangeBoundable<T> range)
- Compares a point to a range.
- Parameters:
point
- given pointrange
- given range
- Returns:
- zero if the given point is within the given range (inclusive);
less than zero if the point is below the range; or
greater than zero if the point is above the range.