Package VASSAL.tools.concurrent
Class ConcurrentSoftHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
VASSAL.tools.concurrent.ConcurrentSoftHashMap<K,V>
- All Implemented Interfaces:
ConcurrentMap<K,V>,Map<K,V>
public class ConcurrentSoftHashMap<K,V> extends AbstractMap<K,V> implements ConcurrentMap<K,V>
A memory-sensitive
ConcurrentMap which stores the values
in SoftReferences. This ConcurrentMap grows
without bound, but when the JVM is under memory pressure, values
held by it may be garbage collected.
All methods except get(java.lang.Object) cause the Map to
be cleared of key-value pairs for which the value has been garbage
collected. Processing key-value pairs with dead values is not
an atomic operation. Thus, it is possible, though unlikely, that more
values will be garbage collected between the removal of dead key-value
pairs and the return of the method in which this takes place.
This implementation does not permit null keys or
values.
- Since:
- 3.1.0
- Author:
- Joel Uckelman
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConcurrentSoftHashMap.SimpleEntry<K,V>An implementation ofMap.Entry.Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object> -
Constructor Summary
Constructors Constructor Description ConcurrentSoftHashMap() -
Method Summary
Modifier and Type Method Description voidclear()booleancontainsKey(Object key)Set<Map.Entry<K,V>>entrySet()Vget(Object key)Vput(K key, V value)VputIfAbsent(K key, V value)Vremove(Object key)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)intsize()Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, valuesMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Constructor Details
-
ConcurrentSoftHashMap
public ConcurrentSoftHashMap()
-
-
Method Details
-
size
public int size() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>- Overrides:
containsKeyin classAbstractMap<K,V>
-
get
-
put
-
remove
-
clear
public void clear() -
entrySet
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>
-
remove
-
replace
-
replace
-