Package org.biojava.utils.io
Class SoftHashMap
- java.lang.Object
-
- java.util.AbstractMap
-
- org.biojava.utils.io.SoftHashMap
-
- All Implemented Interfaces:
Map
public class SoftHashMap extends AbstractMap
A in memory cache using soft references. (can be garbage collected) This code is based on: http://java-interview-faqs.blogspot.com/2008/09/building-faster-and-efficient-cache.html
-
-
Nested Class Summary
-
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>
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
DEBUG
static int
DEFAULT_LIMIT
-
Constructor Summary
Constructors Constructor Description SoftHashMap()
SoftHashMap(int hardSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Set
entrySet()
Object
get(Object key)
Object
put(Object key, Object value)
Here we put the key, value pair into the HashMap using a SoftValue object.Object
remove(Object key)
int
size()
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Field Detail
-
DEBUG
public static final boolean DEBUG
- See Also:
- Constant Field Values
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SoftHashMap
public SoftHashMap()
-
SoftHashMap
public SoftHashMap(int hardSize)
-
-
Method Detail
-
get
public Object get(Object key)
- Specified by:
get
in interfaceMap
- Overrides:
get
in classAbstractMap
-
put
public Object put(Object key, Object value)
Here we put the key, value pair into the HashMap using a SoftValue object.- Specified by:
put
in interfaceMap
- Overrides:
put
in classAbstractMap
-
remove
public Object remove(Object key)
- Specified by:
remove
in interfaceMap
- Overrides:
remove
in classAbstractMap
-
clear
public void clear()
- Specified by:
clear
in interfaceMap
- Overrides:
clear
in classAbstractMap
-
size
public int size()
- Specified by:
size
in interfaceMap
- Overrides:
size
in classAbstractMap
-
-