Class WeakIdentityMap<K,V>
- All Implemented Interfaces:
Map<K,V>
The documentation for WeakHashMap states that it is intended primarily for use with key objects whose equals methods test for object identity using the == operator. Because WeakIdentityMap strictly follows this behavior, it is better suited for this purpose.
Note: Weakly referenced entries may be automatically removed during either accessor or mutator operations, possibly causing a concurrent modification to be detected. Therefore, even if multiple threads are only accessing this map, be sure to synchronize this map first. Also, do not rely on the value returned by size() when using an iterator from this map. The iterators may return less entries than the amount reported by size().
- Since:
- 6.0.0
- Author:
- Brian S O'Neill
-
Nested Class Summary
Nested 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
ConstructorsConstructorDescriptionWeakIdentityMap(int initialCapacity) WeakIdentityMap(int initialCapacity, float loadFactor) WeakIdentityMap(Map<? extends K, ? extends V> t) -
Method Summary
Methods inherited from class java.util.AbstractMap
equals, hashCodeMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Constructor Details
-
WeakIdentityMap
public WeakIdentityMap(int initialCapacity, float loadFactor) -
WeakIdentityMap
public WeakIdentityMap(int initialCapacity) -
WeakIdentityMap
public WeakIdentityMap() -
WeakIdentityMap
-
-
Method Details
-
toString
Gets the map as a String.- Overrides:
toStringin classAbstractMap<K,V> - Returns:
- a string version of the map
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V>
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
clone
- Overrides:
clonein classAbstractMap<K,V>
-
keySet
-
values
-
entrySet
-