SortedMap to fix the size blocking add/remove.
Any action that would change the size of the map is disallowed. The put method is allowed to change the value associated with an existing key however.
If trying to remove or clear the map, an UnsupportedOperationException is thrown. If trying to put a new mapping into the map, an IllegalArgumentException is thrown. This is because the put method can succeed if the mapping's key already exists in the map, so the put method is not always unsupported.
Note that FixedSizeSortedMap is not synchronized and is not thread-safe.
If you wish to use this map from multiple threads concurrently, you must use
appropriate synchronization. The simplest approach is to wrap this map
using java.. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Serialization version |
| Access | Constructor and Description |
|---|---|
| protected | FixedSizeSortedMap(final SortedMap<K, V>
the map to decorate, must not be null map)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Overrides org. Implements java. |
| public Set | entrySet()
Overrides org. Implements java. Set view of the mappings contained in this map.
|
| public static < the key type K, the value type V> FixedSizeSortedMap | Returns: a new fixed size sorted mapthe map to decorate, must not be null map)Factory method to create a fixed size sorted map. |
| protected SortedMap | |
| public SortedMap | headMap(final K
high endpoint (exclusive) of the keys in the returned map toKey)Overrides org. Implements java. toKey.
|
| public boolean | isFull()
Implements org. |
| public Set | keySet()
Overrides org. Implements java. Set view of the keys contained in this map.
|
| public int | maxSize()
Implements org. |
| public V | put(final K
key with which the specified value is to be associated key, final V value to be associated with the specified key value)Overrides org. Implements java. |
| public void | putAll(final Map<? extends K, ? extends V>
mappings to be stored in this map mapToCopy)Overrides org. Implements java. |
| private void | |
| public V | remove(final Object
key whose mapping is to be removed from the map key)Overrides org. Implements java. |
| public SortedMap | subMap(final K
low endpoint (inclusive) of the keys in the returned map fromKey, final K high endpoint (exclusive) of the keys in the returned map toKey)Overrides org. Implements java. fromKey, inclusive, to toKey, exclusive.
|
| public SortedMap | tailMap(final K
low endpoint (inclusive) of the keys in the returned map fromKey)Overrides org. Implements java. fromKey.
|
| public Collection | values()
Overrides org. Implements java. Collection view of the values contained in this map.
|
| private void |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Serialization version | |
| FixedSizeSortedMap | back to summary |
|---|---|
| protected FixedSizeSortedMap(final SortedMap<K, V> map) Constructor that wraps (not copies).
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| entrySet | back to summary |
|---|---|
| public Set Overrides org. Implements java. Doc from java. Returns a | |
| fixedSizeSortedMap | back to summary |
|---|---|
| public static <K, V> FixedSizeSortedMap Factory method to create a fixed size sorted map.
| |
| getSortedMap | back to summary |
|---|---|
| protected SortedMap Gets the map being decorated.
| |
| headMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an | |
| isFull | back to summary |
|---|---|
| public boolean isFull() Implements org. Doc from org. Returns true if this map is full and no new elements can be added.
| |
| keySet | back to summary |
|---|---|
| public Set Overrides org. Implements java. Doc from java. Returns a | |
| maxSize | back to summary |
|---|---|
| public int maxSize() Implements org. Doc from org. Gets the maximum size of the map (the bound).
| |
| put | back to summary |
|---|---|
| public V put(final K key, final V value) Overrides org. Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| putAll | back to summary |
|---|---|
| public void putAll(final Map<? extends K, ? extends V> mapToCopy) Overrides org. Implements java. Doc from java. Copies all of the mappings from the specified map to this map
(optional operation). The effect of this call is equivalent to that
of calling | |
| readObject | back to summary |
|---|---|
| private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException Read the map in using a custom routine.
| |
| remove | back to summary |
|---|---|
| public V remove(final Object key) Overrides org. Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns. | |
| subMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an | |
| tailMap | back to summary |
|---|---|
| public SortedMap Overrides org. Implements java. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an | |
| values | back to summary |
|---|---|
| public Collection Overrides org. Implements java. Doc from java. Returns a
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(final ObjectOutputStream out) throws IOException Write the map out using a custom routine.
| |