Package com.luciad.util.collections
Class TLcdWeakIdentityHashMap<K,V>
java.lang.Object
com.luciad.util.collections.TLcdWeakIdentityHashMap<K,V>
- All Implemented Interfaces:
ILcdCloneable,Cloneable,Map<K,V>
Hash map implementation with weak keys and identity-based comparison semantics. Keys are weakly
referenced and not protected from a potential garbage collection. If a key becomes garbage
collected, the corresponding entry is discarded. Cleanup is not asynchronous; it piggybacks on
other operations. See
WeakHashMap for a more detailed discussion.- Since:
- 2012.0
-
Nested Class Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new map with an initial capacity of 16 and load factor of 0.75.TLcdWeakIdentityHashMap(int aInitialCapacity) Creates a new map with the given initial capacity and load factor of 0.75.TLcdWeakIdentityHashMap(int aInitialCapacity, float aLoadFactor) Creates a new map with the given initial capacity and the given load factor.TLcdWeakIdentityHashMap(Map aMap) Creates a new map containing all entries in the given map. -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()clone()MakesObject.clone()public.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanisEmpty()keySet()protected voidCalled when an entry is removed from the map (either by explicitly removing it, when it's overridden, or when it was removed because it was unreferenced)voidintsize()toString()values()Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, 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
-
TLcdWeakIdentityHashMap
public TLcdWeakIdentityHashMap()Creates a new map with an initial capacity of 16 and load factor of 0.75. -
TLcdWeakIdentityHashMap
public TLcdWeakIdentityHashMap(int aInitialCapacity) Creates a new map with the given initial capacity and load factor of 0.75.- Parameters:
aInitialCapacity- the initial capacity of the map
-
TLcdWeakIdentityHashMap
public TLcdWeakIdentityHashMap(int aInitialCapacity, float aLoadFactor) Creates a new map with the given initial capacity and the given load factor.- Parameters:
aInitialCapacity- the initial capacity of the mapaLoadFactor- the load factor- See Also:
-
TLcdWeakIdentityHashMap
Creates a new map containing all entries in the given map. The effect of this constructor is equivalent to that of callingput(k, v)on this map once for each mapping from key k to value v in the specified map.- Parameters:
aMap- the map whose entries to load into this map.- See Also:
-
-
Method Details
-
onRemove
Called when an entry is removed from the map (either by explicitly removing it, when it's overridden, or when it was removed because it was unreferenced)- Parameters:
aKey- the key. Can benullif it was unreferenced (when not hard-referenced anymore).aValue- the value
-
size
public int size() -
isEmpty
public boolean isEmpty() -
entrySet
It is not allowed to access the map (for example calling
get) while iterating over the result of this method, except via theIterator.removemethod. Not doing so may lead toConcurrentModificationExceptions in rare cases. -
keySet
It is not allowed to access the map (for example calling
get) while iterating over the result of this method, except via theIterator.removemethod. Not doing so may lead toConcurrentModificationExceptions in rare cases. -
putAll
-
get
-
remove
-
put
-
clear
public void clear() -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V>
-
values
-
clone
Description copied from interface:ILcdCloneableMakes
When for example extending fromObject.clone()public.java.lang.Object, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }- Specified by:
clonein interfaceILcdCloneable- Overrides:
clonein classObject- See Also:
-
toString
-