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
ConstructorDescriptionCreates 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 TypeMethodDescriptionvoid
clear()
clone()
MakesObject.clone()
public.boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
isEmpty()
keySet()
protected void
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)void
int
size()
toString()
values()
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 benull
if 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.remove
method. Not doing so may lead toConcurrentModificationException
s 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.remove
method. Not doing so may lead toConcurrentModificationException
s in rare cases. -
putAll
-
get
-
remove
-
put
-
clear
public void clear() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
values
-
clone
Description copied from interface:ILcdCloneable
Makes
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:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classObject
- See Also:
-
toString
-