Class ManagedIdentityConcurrentMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
org.apache.groovy.util.concurrent.ConcurrentReferenceHashMap<K,V>
org.apache.groovy.util.concurrent.ManagedIdentityConcurrentMap<K,V>
- Type Parameters:
K
- the key typeV
- the value type
- All Implemented Interfaces:
Serializable
,Map<K,
V>
This is a basic implementation of a map able to forget its keys could be weak/soft/strong references. This
bases on
ConcurrentReferenceHashMap
, thus it is safe for concurrency.
This map compares keys through references.- Since:
- 4.0.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.groovy.util.concurrent.ConcurrentReferenceHashMap
ConcurrentReferenceHashMap.HashIterator, ConcurrentReferenceHashMap.InitializableEntry<K,
V>, ConcurrentReferenceHashMap.Option, ConcurrentReferenceHashMap.ReferenceType, ConcurrentReferenceHashMap.SimpleEntry<K, V>, ConcurrentReferenceHashMap.WriteThroughEntry Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleImmutableEntry<K extends Object,
V extends Object> -
Constructor Summary
ConstructorDescriptionCreates a new, empty map with the key weak referenceManagedIdentityConcurrentMap
(int initialCapacity) Creates a new, empty map with the key weak reference and the specified initial capacityCreates a new, empty map with the specified key reference typeManagedIdentityConcurrentMap
(ConcurrentReferenceHashMap.ReferenceType keyType, int initialCapacity) Creates a new, empty map with the specified key reference type and initial capacity -
Method Summary
Methods inherited from class org.apache.groovy.util.concurrent.ConcurrentReferenceHashMap
apply, applyIfAbsent, applyIfPresent, cachedEntrySet, clear, contains, containsKey, containsValue, elements, entrySet, get, hashOf, isEmpty, keys, keySet, purgeStaleEntries, put, putAll, putIfAbsent, remove, remove, replace, replace, size, values
Methods inherited from class java.util.AbstractMap
clone, equals, hashCode, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, replaceAll
-
Constructor Details
-
ManagedIdentityConcurrentMap
public ManagedIdentityConcurrentMap()Creates a new, empty map with the key weak reference -
ManagedIdentityConcurrentMap
public ManagedIdentityConcurrentMap(int initialCapacity) Creates a new, empty map with the key weak reference and the specified initial capacity- Parameters:
initialCapacity
- initial capacity
-
ManagedIdentityConcurrentMap
Creates a new, empty map with the specified key reference type- Parameters:
keyType
- key reference type
-
ManagedIdentityConcurrentMap
public ManagedIdentityConcurrentMap(ConcurrentReferenceHashMap.ReferenceType keyType, int initialCapacity) Creates a new, empty map with the specified key reference type and initial capacity- Parameters:
keyType
- key reference typeinitialCapacity
- the initial capacity
-
-
Method Details
-
getOrPut
Get the key specified value, or put the default value and return it if the key is absent- Parameters:
key
- the key to look upvalue
- the default value if the key is absent- Returns:
- the value
-