Package org.jivesoftware.smack.util
Class CleaningWeakReferenceMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,java.lang.ref.WeakReference<V>>
-
- org.jivesoftware.smack.util.CleaningWeakReferenceMap<K,V>
-
- Type Parameters:
K
- The key type.V
- The value type.
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<K,java.lang.ref.WeakReference<V>>
public class CleaningWeakReferenceMap<K,V> extends java.util.HashMap<K,java.lang.ref.WeakReference<V>>
Extends aHashMap
withWeakReference
values, so that weak references which have been cleared are periodically removed from the map. The cleaning occurs as part ofput(K, java.lang.ref.WeakReference<V>)
, after a specific number (cleanInterval
) of calls toput(K, java.lang.ref.WeakReference<V>)
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description CleaningWeakReferenceMap()
Initializes a newCleaningWeakReferenceMap
instance with the default clean interval.CleaningWeakReferenceMap(int cleanInterval)
Initializes a newCleaningWeakReferenceMap
instance with a given clean interval.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ref.WeakReference<V>
put(K key, java.lang.ref.WeakReference<V> value)
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Constructor Detail
-
CleaningWeakReferenceMap
public CleaningWeakReferenceMap()
Initializes a newCleaningWeakReferenceMap
instance with the default clean interval.
-
CleaningWeakReferenceMap
public CleaningWeakReferenceMap(int cleanInterval)
Initializes a newCleaningWeakReferenceMap
instance with a given clean interval.- Parameters:
cleanInterval
- the number of calls toput(K, java.lang.ref.WeakReference<V>)
after which the map will clean itself.
-
-