Rice Pastry API

rice.p2p.util
Class SoftHashMap

java.lang.Object
  extended byjava.util.AbstractMap
      extended byjava.util.HashMap
          extended byrice.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

Constructor Summary
SoftHashMap()
           
 
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
 

Constructor Detail

SoftHashMap

public SoftHashMap()
Method Detail

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 key
value - The value
Returns:
The previous value of the key

Rice Pastry API

Copyright © 2001-2005 - Rice Pastry.


Imprint-Dataprotection