|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.util.AbstractMap | +--com.beasys.commerce.util.SoftHashMap
A map implemented using SoftReferences to store the values.
Unlike the java.util.WeakHashMap
implementation, this does
not utilize a ReferenceQueue, therefore, the References are cleared
immediately, rather than only after a modification to the Map.
Additionally, since this uses SoftReferences by default, the Map shouldn't
be immediately cleared. Finally, this is also cloneable and
serializable.
Inner classes inherited from class java.util.Map |
java.util.Map.Entry |
Constructor Summary | |
SoftHashMap()
Constructs a new, empty SoftHashMap with the default
capacity and the default load factor, which is 0.75 . |
|
SoftHashMap(int initialCapacity)
Constructs a new, empty SoftHashMap with the given
initial capacity and the default load factor, which is
0.75 . |
|
SoftHashMap(int initialCapacity,
float loadFactor)
Constructs a new, empty SoftHashMap with the given
initial capacity and the given load factor. |
|
SoftHashMap(java.util.Map map)
Constructs a new SoftHashMap from the specified Map. |
Method Summary | |
void |
clear()
Removes all mappings from this map. |
java.lang.Object |
clone()
Return a shallow clone of this map. |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains a mapping for the
specified key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map contains the specified value. |
protected java.lang.ref.Reference |
createReference(java.lang.Object data)
Create a Reference object containing the specified object. |
java.util.Set |
entrySet()
Returns a Set view of the mappings in this map. |
java.lang.Object |
get(java.lang.Object key)
Returns the value to which this map maps the specified key . |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Updates this map so that the given key maps to the given
value . |
java.lang.Object |
remove(java.lang.Object key)
Removes the mapping for the given key from this map, if
present. |
int |
size()
Returns the number of key-value mappings in this map. |
Methods inherited from class java.util.AbstractMap |
equals,
hashCode,
keySet,
putAll,
toString,
values |
Methods inherited from class java.lang.Object |
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public SoftHashMap(int initialCapacity, float loadFactor)
SoftHashMap
with the given
initial capacity and the given load factor.initialCapacity
- The initial capacity of the
SoftHashMap
loadFactor
- The load factor of the SoftHashMap
public SoftHashMap(int initialCapacity)
SoftHashMap
with the given
initial capacity and the default load factor, which is
0.75
.initialCapacity
- The initial capacity of the
SoftHashMap
public SoftHashMap()
SoftHashMap
with the default
capacity and the default load factor, which is 0.75
.public SoftHashMap(java.util.Map map)
SoftHashMap
from the specified Map.Method Detail |
public java.lang.Object clone()
protected java.lang.ref.Reference createReference(java.lang.Object data)
This implementation returns SoftReferences. Subclasses can override to return other Reference types.
data
- the object (can be null).public int size()
Map
interface, the time required by this operation is
linear in the size of the map.public boolean isEmpty()
true
if this map contains no key-value mappings.public boolean containsKey(java.lang.Object key)
true
if this map contains a mapping for the
specified key.key
- The key whose presence in this map is to be testedpublic boolean containsValue(java.lang.Object value)
true
if this map contains the specified value.public java.lang.Object get(java.lang.Object key)
key
.
If this map does not contain a value for this key, then return
null
.key
- The key whose associated value, if any, is to be returnedpublic java.lang.Object put(java.lang.Object key, java.lang.Object value)
key
maps to the given
value
. If the map previously contained a mapping for
key
then that mapping is replaced and the previous value is
returned.key
- The key that is to be mapped to the given
value
value
- The value to which the given key
is to be
mappednull
if if there was no mapping for the keypublic java.lang.Object remove(java.lang.Object key)
key
from this map, if
present.key
- The key whose mapping is to be removednull
if
there was no mapping for the keypublic void clear()
public java.util.Set entrySet()
Set
view of the mappings in this map.
|
BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |