Modified version of
org.apache.commons.collections.ReferenceMap , using
object identity for key comparison (). This class
simply extended
org.apache.commons.collections.ReferenceMap with an extra field
"useSystemIdentity" which is initialized in constructor and is used every time we
want to compare (or hash) keys or values.
Javadoc of ReferenceMap starts here:
Hashtable-based
java.util.Map implementation that allows
mappings to be removed by the garbage collector.
When you construct a ReferenceMap , you can
specify what kind of references are used to store the
map's keys and values. If non-hard references are
used, then the garbage collector can remove mappings
if a key or value becomes unreachable, or if the
JVM's memory is running low. For information on how
the different reference types behave, see
java.lang.ref.Reference .
Different types of references can be specified for keys
and values. The keys can be configured to be weak but
the values hard, in which case this class will behave
like a
WeakHashMap . However, you
can also specify hard keys and weak values, or any other
combination. The default constructor uses hard keys
and soft values, providing a memory-sensitive cache.
The algorithms used are basically the same as those
in
java.util.HashMap . In particular, you
can specify a load factor and capacity to suit your
needs. All optional
java.util.Map operations are
supported.
However, this
java.util.Map implementation does not
allow null elements. Attempting to add a null key or
or a null value to the map will raise a
NullPointerException .
As usual, this implementation is not synchronized. You
can use
java.util.Collections.synchronizedMap to
provide synchronized access to a ReferenceMap .
org.apache.commons.collections.map.ReferenceIdentityMap author: Andy Malakov version: $Id: ReferenceMap.java,v 1.6.2.2 2005/12/21 22:27:47 tomdz Exp $ |