rice.p2p.util
Class SoftHashMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
rice.p2p.util.SoftHashMap
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map
public class SoftHashMap
- extends java.util.HashMap
Class which implements a Soft-Reference based HashMap, allowing the garbage
collector to collection stuff if memory pressure is tight. Should be transparent
to applications, except that items may disappear.
- Author:
- Alan Mislove
- See Also:
- Serialized Form
Method Summary |
boolean |
containsKey(java.lang.Object key)
Returns whether or not the key is contained in this map. |
boolean |
containsValue(java.lang.Object value)
Returns whether or not the value is contained in this map. |
java.lang.Object |
get(java.lang.Object key)
Returns the object associated with the key. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Adds an entry to the soft hash map. |
Methods inherited from class java.util.HashMap |
clear, clone, entrySet, isEmpty, keySet, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
SoftHashMap
public SoftHashMap()
containsKey
public boolean containsKey(java.lang.Object key)
- Returns whether or not the key is contained in this map. Only returns true if
the softreference has not been GC'ed.
- Specified by:
containsKey
in interface java.util.Map
- Overrides:
containsKey
in class java.util.HashMap
- Parameters:
key
- The key to check for
- Returns:
- The result
containsValue
public boolean containsValue(java.lang.Object value)
- Returns whether or not the value is contained in this map. Only returns true if
the softreference has not been GC'ed.
- Specified by:
containsValue
in interface java.util.Map
- Overrides:
containsValue
in class java.util.HashMap
- Parameters:
value
- The value to check for
- Returns:
- The result
get
public java.lang.Object get(java.lang.Object key)
- Returns the object associated with the key. May return null, if the soft reference
has been GC'ed.
- Specified by:
get
in interface java.util.Map
- Overrides:
get
in class java.util.HashMap
- Parameters:
key
- The key
- Returns:
- The value
put
public java.lang.Object put(java.lang.Object key,
java.lang.Object value)
- Adds an entry to the soft hash map. May not persist for very long, though.
- Specified by:
put
in interface java.util.Map
- Overrides:
put
in class java.util.HashMap
- Parameters:
key
- The keyvalue
- The value
- Returns:
- The previous value of the key
Copyright © 2001-2005 - Rice Pastry.