Class ReferenceValueMap2<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
org.eclipse.net4j.util.ref.ReferenceValueMap2<K,V>
- Type Parameters:
K- the key typeV- the value type
- All Implemented Interfaces:
Map<K,V>
- Direct Known Subclasses:
ReferenceValueMap, ReferenceValueMap2.Soft, ReferenceValueMap2.Strong, ReferenceValueMap2.Weak
A
Map implementation that uses KeyedReference instances (KeyedStrongReference,
KeyedSoftReference, KeyedWeakReference or KeyedPhantomReference) as its values.
A ReferenceValueMap can be used to cache mappings until the value of the mapping is no longer
reachable from outside of the map
Note: This map is not synchronized. If it is to be used by multiple threads concurrently the user is responsible for applying proper external synchronization!
- Since:
- 3.3
- Author:
- Eike Stepper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA reference-value map that keeps values softly reachable.static classA reference-value map that keeps values strongly reachable.static classA reference-value map that keeps values weakly reachable.Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) protected ReferenceQueue<V> protected abstract KeyedReference<K, V> createReference(K key, V value, ReferenceQueue<V> queue) protected Vdereference(KeyedReference<K, V> ref) entrySet()protected intbooleanisEmpty()protected voidprotected voidremoveAll(BiPredicate<K, V> predicate) intsize()Methods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
ReferenceValueMap2
public ReferenceValueMap2() -
ReferenceValueMap2
-
-
Method Details
-
size
-
isEmpty
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V>
-
get
-
put
-
remove
-
removeAll
- Since:
- 3.16
-
clear
-
entrySet
-
createQueue
-
internalPurgeQueue
protected int internalPurgeQueue()- Since:
- 3.7
-
purgeQueue
protected void purgeQueue() -
purged
-
dereference
-
createReference
-