Package org.biojava.utils.io
Class SoftHashMap
- java.lang.Object
-
- java.util.AbstractMap
-
- org.biojava.utils.io.SoftHashMap
-
- All Implemented Interfaces:
java.util.Map
public class SoftHashMap extends java.util.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
-
-
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()
java.util.Set
entrySet()
java.lang.Object
get(java.lang.Object key)
java.lang.Object
put(java.lang.Object key, java.lang.Object value)
Here we put the key, value pair into the HashMap using a SoftValue object.java.lang.Object
remove(java.lang.Object key)
int
size()
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values
-
-
-
-
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 java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map
- Overrides:
get
in classjava.util.AbstractMap
-
put
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
Here we put the key, value pair into the HashMap using a SoftValue object.- Specified by:
put
in interfacejava.util.Map
- Overrides:
put
in classjava.util.AbstractMap
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map
- Overrides:
remove
in classjava.util.AbstractMap
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map
- Overrides:
clear
in classjava.util.AbstractMap
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map
- Overrides:
size
in classjava.util.AbstractMap
-
entrySet
public java.util.Set entrySet()
- Specified by:
entrySet
in interfacejava.util.Map
- Specified by:
entrySet
in classjava.util.AbstractMap
-
-