|
||||||||||
| 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>
org.gcube.common.vremanagement.deployer.impl.state.CountableHashMap<K,V>
K - the key typeV - the value typepublic class CountableHashMap<K,V>
An extension of the standard HashMap handling multiple instances of the same key, all mapped on the same value.
This extension behaves as follows:
put(Object, Object) or a putAll(Map) are invoked, if the given key exists,
a counter for the key is increased, otherwise the element is added to the CountableHashMap object and a new counter is created.
remove(Object) is invoked, the key is removed only if the related counter value is 1.
HashMap,
Map,
Serialized Form| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.util.AbstractMap |
|---|
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V> |
| Constructor Summary | |
|---|---|
CountableHashMap()
|
|
CountableHashMap(int initialCapacity)
|
|
CountableHashMap(int initialCapacity,
float loadFactor)
|
|
CountableHashMap(Map<K,V> m)
|
|
| Method Summary | |
|---|---|
void |
clear()
|
int |
countablePut(K key,
V value)
Associates the specified value with the specified key in this map. |
Map<? extends K,Integer> |
countablePutAll(Map<? extends K,? extends V> m)
Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map. |
int |
countableRemove(Object key)
Removes the mapping for this key from this CountableHashMap if present |
int |
getCounter(Object key)
Gets the key counter of the given element |
V |
put(K key,
V value)
|
void |
putAll(Map<? extends K,? extends V> m)
|
V |
remove(Object key)
|
| Methods inherited from class java.util.HashMap |
|---|
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, 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 |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public CountableHashMap()
public CountableHashMap(int initialCapacity)
public CountableHashMap(Map<K,V> m)
public CountableHashMap(int initialCapacity,
float loadFactor)
| Method Detail |
|---|
public void clear()
clear in interface Map<K,V>clear in class HashMap<K,V>
public V put(K key,
V value)
put in interface Map<K,V>put in class HashMap<K,V>public void putAll(Map<? extends K,? extends V> m)
putAll in interface Map<K,V>putAll in class HashMap<K,V>public V remove(Object key)
remove in interface Map<K,V>remove in class HashMap<K,V>public int countableRemove(Object key)
key - key whose mapping is to be removed from the map
public int countablePut(K key,
V value)
key - key with which the specified value is to be associatedvalue - value to be associated with the specified key
public Map<? extends K,Integer> countablePutAll(Map<? extends K,? extends V> m)
m - mappings to be stored in this map.
NullPointerException - if the specified map is null.public int getCounter(Object key)
key - the key to count
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||