rice.p2p.util
Class SoftHashMap
java.lang.Object
java.util.AbstractMap
java.util.HashMap
rice.p2p.util.SoftHashMap
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Map, java.io.Serializable
- 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.
- Version:
- $Id: pretty.settings 2305 2005-03-11 20:22:33Z jeffh $
- 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()
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.
- Parameters:
key
- The key
- Returns:
- The value
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.
- 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.
- Parameters:
value
- The value to check for
- Returns:
- The result
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.
- Parameters:
key
- The keyvalue
- The value
- Returns:
- The previous value of the key
Copyright © 2001-2005 - Rice Pastry.