Class ConcurrentWeakHashMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
de.hybris.platform.util.collections.ConcurrentWeakHashMap<K,V>
- All Implemented Interfaces:
ConcurrentMap<K,,V> Map<K,V>
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new, empty HashMap with a default capacity and load factor.ConcurrentWeakHashMap(int initialCapacity) Constructs a new, empty HashMap with the specified initial capacity and default load factor.ConcurrentWeakHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) Constructs a new, empty HashMap with the specified initial capacity and the specified load factor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all mappings from all segment, leaving the ConcurrentWeakHashMap empty.booleancontainsKey(Object key) entrySet()Returns the value to which this HashMap maps the specified key.getOrPut(K key, ConcurrentWeakHashMap.LazyValueCreator<K, V> valueCreator) Checks if a value is already mapped and returns that one.keySet()putIfAbsent(K key, V value) booleanbooleanintsize()This function is not accurate under concurrent environment.Methods inherited from class java.util.AbstractMap
clone, containsValue, equals, hashCode, isEmpty, 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
-
ConcurrentWeakHashMap
public ConcurrentWeakHashMap(int initialCapacity, float loadFactor, int concurrencyLevel) Constructs a new, empty HashMap with the specified initial capacity and the specified load factor.- Parameters:
initialCapacity- the initial capacity of the HashMap.loadFactor- a number between 0.0 and 1.0.concurrencyLevel- the estimated number of concurrently updating threads. The implementation performs internal sizing to try to accommodate this many threads.- Throws:
IllegalArgumentException- if neither keys nor values use hard references, if the initial capacity is less than or equal to zero, or if the load factor is less than or equal to zero
-
ConcurrentWeakHashMap
public ConcurrentWeakHashMap(int initialCapacity) Constructs a new, empty HashMap with the specified initial capacity and default load factor.- Parameters:
initialCapacity- the initial capacity of the HashMap.
-
ConcurrentWeakHashMap
public ConcurrentWeakHashMap()Constructs a new, empty HashMap with a default capacity and load factor.
-
-
Method Details
-
put
-
get
Returns the value to which this HashMap maps the specified key. Returns null if the HashMap contains no mapping for this key. -
remove
-
remove
-
size
public int size()This function is not accurate under concurrent environment. -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
clear
public void clear()Clear all mappings from all segment, leaving the ConcurrentWeakHashMap empty. -
keySet
-
getOrPut
Checks if a value is already mapped and returns that one. If it does not find that key a new value is lazily created and returned as result.Please note that the returned value is always the one which stays inside the map after that call, which is totally different to traditional methods like put or putIfAbsent!
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
replace
-
replace
-
entrySet
-