public class BoundedSortedMap<K,V> extends TreeMap<K,V>
Map
implementation that grows to a fixed size and then retains only
a fixed number of the highest (largest) keys. All keys used in this class
must implements Comparable
.BoundedSortedMultiMap
,
Serialized FormAbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
BoundedSortedMap(int bound)
Creatins an instance that will only retain the specified number of the
largest (highest) keys.
|
BoundedSortedMap(int bound,
boolean retainHighest)
Creatins an instance that will only retain the specified number of keys,
where the largest (highest) keys.
|
Modifier and Type | Method and Description |
---|---|
V |
put(K key,
V value)
Adds the key-value mapping to this map, and if the total number of
mappings exceeds the bounds, removes either the currently lowest element,
or if reversed, the currently highest element.
|
void |
putAll(Map<? extends K,? extends V> m)
Adds all of the key-value mapping to this map, and if the total number of
mappings exceeds the bounds, removes mappings until the size is within
bounds.
|
ceilingEntry, ceilingKey, clear, clone, comparator, containsKey, containsValue, descendingKeySet, descendingMap, entrySet, firstEntry, firstKey, floorEntry, floorKey, get, headMap, headMap, higherEntry, higherKey, keySet, lastEntry, lastKey, lowerEntry, lowerKey, navigableKeySet, pollFirstEntry, pollLastEntry, remove, size, subMap, subMap, tailMap, tailMap, values
equals, hashCode, isEmpty, toString
public BoundedSortedMap(int bound)
bound
- the number of mappings to retainpublic BoundedSortedMap(int bound, boolean retainHighest)
bound
- the number of mappings to retainretainHighest
- true
if the highest elements are to be
retained, false
if the lowest keys are to be retainedpublic V put(K key, V value)
Copyright © 2012. All Rights Reserved.