java.lang.Object
org.litebridge.commons.type.WeakIdentityMap<K,V>
- Type Parameters:
K- the type of keys maintained by this mapV- the type of mapped values
- All Implemented Interfaces:
Map<K,V>
A Map implementation that uses weak references for keys and compares keys using identity comparison (==).
This implementation automatically removes entries when their keys are no longer strongly reachable.
This is useful for caching scenarios where: - Keys should be automatically removed when they're no longer referenced elsewhere - Key equality should be based on identity rather than equals()
- See Also:
-
Nested Class Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()@Nullable VbooleanisEmpty()keySet()@Nullable Vvoid@Nullable Vintsize()Collection<@Nullable V> values()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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()
-
-
Method Details
-
put
-
get
-
remove
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
size
public int size() -
isEmpty
public boolean isEmpty() -
clear
public void clear() -
putAll
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
keySet
-
values
-
entrySet
-