Class AbstractSoftMap<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- com.helger.commons.collection.map.AbstractSoftMap<K,V>
-
- Type Parameters:
K- Key typeV- Value type
- All Implemented Interfaces:
ICommonsMap<K,V>,ICloneable<ICommonsMap<K,V>>,Map<K,V>
- Direct Known Subclasses:
SoftHashMap,SoftLinkedHashMap
public abstract class AbstractSoftMap<K,V> extends AbstractMap<K,V> implements ICommonsMap<K,V>
SoftMapimplementation based on http://www.javaspecialists.eu/archive/Issue015.html
TheentrySetimplementation is fromorg.hypergraphdb.util
Note:AbstractSoftMapis NOT serializable!- Author:
- Philip Helger
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractSoftMap.SoftValue<K,V>We define our own subclass of SoftReference which contains not only the value but also the key to make it easier to find the entry in the HashMap after it's been garbage collected.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSoftMap(Map<K,AbstractSoftMap.SoftValue<K,V>> aSrcMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Set<Map.Entry<K,V>>entrySet()booleanequals(Object o)Vget(Object aKey)inthashCode()protected voidonEntryRemoved(K aKey)Callback method invoked after a map entry is garbage collectedVput(K aKey, V aValue)Here we put the key, value pair into the HashMap using a SoftValue object.Vremove(Object aKey)intsize()-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, isEmpty, keySet, putAll, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.lang.ICloneable
getClone
-
Methods inherited from interface com.helger.commons.collection.impl.ICommonsMap
addAll, containsAnyEntry, containsAnyKey, containsAnyValue, copyOfEntrySet, copyOfKeySet, copyOfKeySet, copyOfValues, copyOfValues, copyOfValuesMapped, copyOfValuesMapped, createInstance, findFirstEntry, findFirstKey, findFirstValue, forEach, forEachKey, forEachKey, forEachValue, forEachValue, getAsUnmodifiable, getFirstEntry, getFirstEntry, getFirstKey, getFirstKey, getFirstValue, getFirstValue, getSortedByKey, getSortedByValue, getSwappedKeyValues, isNotEmpty, put, putAll, putAll, putAllMapped, putAllMapped, putAllMapped, putIf, putIfNotNull, removeAll, removeIf, removeIfKey, removeIfValue, removeObject, setAll
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, values
-
-
-
-
Field Detail
-
m_aSrcMap
@CodingStyleguideUnaware protected final Map<K,AbstractSoftMap.SoftValue<K,V>> m_aSrcMap
The internal HashMap that will hold the SoftReference.
-
-
Method Detail
-
onEntryRemoved
@OverrideOnDemand protected void onEntryRemoved(K aKey)
Callback method invoked after a map entry is garbage collected- Parameters:
aKey- Key the removed key
-
put
public V put(K aKey, V aValue)
Here we put the key, value pair into the HashMap using a SoftValue object.
-
clear
public void clear()
-
size
public int size()
-
entrySet
@ReturnsMutableObject("design") @CodingStyleguideUnaware public Set<Map.Entry<K,V>> entrySet()
-
equals
public boolean equals(Object o)
-
-