|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,V>
com.mizar.commons.collections.AccumulatorMap<K,V>
public class AccumulatorMap<K,V>
The class extends the standard java.util.HashMap adding methods for sort, increment, and decrement entries.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.util.AbstractMap |
---|
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V> |
Nested classes/interfaces inherited from interface java.util.Map |
---|
java.util.Map.Entry<K,V> |
Constructor Summary | |
---|---|
AccumulatorMap()
Constructs an empty AccumulatorMap with the default initial capacity (16) and the default load factor (0.75). |
|
AccumulatorMap(int initialCapacity)
Constructs an empty AccumulatorMap with the specified initial capacity and the default load factor (0.75). |
|
AccumulatorMap(int initialCapacity,
float loadFactor)
Constructs an empty AccumulatorMap with the specified initial capacity and load factor. |
|
AccumulatorMap(java.util.Map<? extends K,? extends V> m)
Constructs a new AccumulatorMap with the same mappings as the specified Map. |
|
AccumulatorMap(java.util.Map<? extends K,? extends V> m,
java.lang.Number value)
Constructs a new AccumulatorMap with the same keys as the specified Map but all values are set to value
The AccumulatorMap is created with
default load factor (0.75) and an initial capacity sufficient to
hold the mappings in the specified Map. |
Method Summary | |
---|---|
java.lang.Number |
decrement(java.lang.Object key)
|
java.lang.Number |
increment(java.lang.Object key)
The method will ignore any Map that does not have a corresponding entry for key . |
java.lang.Number |
increment(java.lang.Object key,
java.lang.Number value)
The method is null safe for the value associated with this Map's key entry. |
java.lang.Number |
max(java.lang.Object key,
java.lang.Number value)
|
java.lang.Number |
min(java.lang.Object key,
java.lang.Number value)
|
java.lang.Number |
multiply(java.lang.Object key,
java.lang.Number value)
The method is null safe for the value associated with this Map's key entry. |
V |
put(java.lang.Object key,
java.lang.Number value)
The method overrides HashMap.put(K,V) by limiting V to subclasses of Number
Associates the specified numeric value with the specified key in this map. |
AccumulatorMap<? extends K,? extends V> |
sort()
The method does not sort this map. |
Methods inherited from class java.util.HashMap |
---|
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
---|
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
---|
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values |
Constructor Detail |
---|
public AccumulatorMap()
public AccumulatorMap(int initialCapacity, float loadFactor)
initialCapacity
- The initial capacity.loadFactor
- The load factor.
java.lang.IllegalArgumentException
- if the initial capacity is negative
or the load factor is nonpositive.public AccumulatorMap(int initialCapacity)
initialCapacity
- the initial capacity.
java.lang.IllegalArgumentException
- if the initial capacity is negative.public AccumulatorMap(java.util.Map<? extends K,? extends V> m)
m
- the map whose mappings are to be placed in this map.
java.lang.NullPointerException
- if the specified map is null.public AccumulatorMap(java.util.Map<? extends K,? extends V> m, java.lang.Number value)
value
The AccumulatorMap is created with
default load factor (0.75) and an initial capacity sufficient to
hold the mappings in the specified Map.
m
- the map whose mappings are to be placed in this map.
java.lang.NullPointerException
- if the specified map is null.Method Detail |
---|
public V put(java.lang.Object key, java.lang.Number value)
HashMap.put(K,V)
by limiting V to subclasses of Number
Associates the specified numeric value with the specified key in this map.
If the map previously contained a mapping for this key, the old
value is replaced.
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
public java.lang.Number multiply(java.lang.Object key, java.lang.Number value)
key
entry.
If this.get(key)
returns null the key
entry is set to value
.
key
- The key whose presence in this map is to be incremented by value
value
- The value to multiply this map's key
value by
key
value.public java.lang.Number increment(java.lang.Object key, java.lang.Number value)
key
entry.
If this.get(key)
returns null the key
entry is set to value
.
key
- The key whose presence in this map is to be incremented by value
value
- The value to increment this map's key
value by
key
value.public java.lang.Number increment(java.lang.Object key)
key
.
The data type is taken from the existing value associated with key
, which must be a subclass of Number.
key
- The key whose presence in this map is to be incremented by 1
key
value.increment(Object,Number)
public java.lang.Number decrement(java.lang.Object key)
key
- The key whose presence in this map is to be decremented by 1
key
value.public java.lang.Number min(java.lang.Object key, java.lang.Number value)
key
- The key whose presence in this map is to set to the minimum of value
and the existing valuevalue
- The value to compare to this map's key
value
key
value.public java.lang.Number max(java.lang.Object key, java.lang.Number value)
key
- The key whose presence in this map is to set to the maximum of value
and the existing valuevalue
- The value to compare to this map's key
value
key
value.public AccumulatorMap<? extends K,? extends V> sort()
Example:
map = map.sort();
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |