K
- The key type.V
- The value type.public class CleaningWeakReferenceMap<K,V> extends HashMap<K,WeakReference<V>>
HashMap
with WeakReference
values, so that
weak references which have been cleared are periodically removed from
the map. The cleaning occurs as part of put(K, java.lang.ref.WeakReference<V>)
, after a specific
number (cleanInterval
) of calls to put(K, java.lang.ref.WeakReference<V>)
.AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
CleaningWeakReferenceMap()
Initializes a new
CleaningWeakReferenceMap instance with the
default clean interval. |
CleaningWeakReferenceMap(int cleanInterval)
Initializes a new
CleaningWeakReferenceMap instance with a given
clean interval. |
Modifier and Type | Method and Description |
---|---|
WeakReference<V> |
put(K key,
WeakReference<V> value) |
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
equals, hashCode, toString
public CleaningWeakReferenceMap()
CleaningWeakReferenceMap
instance with the
default clean interval.public CleaningWeakReferenceMap(int cleanInterval)
CleaningWeakReferenceMap
instance with a given
clean interval.cleanInterval
- the number of calls to put(K, java.lang.ref.WeakReference<V>)
after which the
map will clean itself.public WeakReference<V> put(K key, WeakReference<V> value)
put
in interface Map<K,WeakReference<V>>
put
in class HashMap<K,WeakReference<V>>