rice.p2p.util
Class SoftHashMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
rice.p2p.util.SoftHashMap
- All Implemented Interfaces:
- Serializable, Cloneable, Map
public class SoftHashMap
- extends 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
SoftHashMap
public SoftHashMap()
containsKey
public boolean containsKey(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 Map- Overrides:
containsKey in class HashMap
- Parameters:
key - The key to check for
- Returns:
- The result
containsValue
public boolean containsValue(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 Map- Overrides:
containsValue in class HashMap
- Parameters:
value - The value to check for
- Returns:
- The result
get
public Object get(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 Map- Overrides:
get in class HashMap
- Parameters:
key - The key
- Returns:
- The value
put
public Object put(Object key,
Object value)
- Adds an entry to the soft hash map. May not persist for very long, though.
- Specified by:
put in interface Map- Overrides:
put in class HashMap
- Parameters:
key - The keyvalue - The value
- Returns:
- The previous value of the key
Copyright © 2010. All Rights Reserved.