|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.walend.collection.AbstractHashMap | +--net.walend.collection.SoftHashMap
This MutableHashMap's values are held by soft references which may disapear if memory gets short. Be prepared for the occasional null value. This class is inherently multithreaded; get the guard from getGuard() if you need to keep other threads out of the map while you work.
Nested Class Summary | |
private class |
SoftHashMap.SoftEntry
Entries for the hash map. |
Nested classes inherited from class net.walend.collection.AbstractHashMap |
|
Field Summary | |
private java.lang.Object |
guard
|
Fields inherited from class net.walend.collection.AbstractHashMap |
|
Fields inherited from interface net.walend.collection.Map |
EMPTY |
Constructor Summary | |
SoftHashMap()
|
|
SoftHashMap(Identitor identitor)
|
|
SoftHashMap(Identitor identitor,
int capacity)
|
|
SoftHashMap(Identitor identitor,
int capacity,
float loadFactor)
|
|
SoftHashMap(int capacity)
|
|
SoftHashMap(int capacity,
float loadFactor)
|
|
SoftHashMap(java.util.Map orig)
|
|
SoftHashMap(Map orig)
|
Method Summary | |
void |
clear()
Removes all key, value pairs from this Map. |
boolean |
containsAll(Map c)
Returns true if this collection contains all of the Objects in the specified collection. |
boolean |
containsKey(java.lang.Object key)
Returns true if this map contains an entry for key. |
boolean |
containsValue(java.lang.Object value)
Returns true if this map contains value. |
java.lang.Object |
get(java.lang.Object key)
Returns the value for the key. |
java.lang.Object |
getGuard()
Return the synchronization guard for this SoftHashMap. |
java.util.Map |
getJavaMap()
Return a java.util.Collection of these Objects. |
Set |
getKeys()
Returns an immutable shallow copy of the Set of keys. |
Collection |
getValues()
Returns an immutable shallow copy of the Collection of values. |
boolean |
isEmpty()
Returns true if this Map has no entries. |
java.util.Iterator |
keyIterator()
Returns an iterator over the keys. |
protected AbstractHashMap.Entry |
newEntry(int hash,
java.lang.Object key,
java.lang.Object value,
AbstractHashMap.Entry next)
Overridden to return entries with soft reference values. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Puts the key,value pair in the map. |
void |
putAll(Map map)
Puts all of the key, value pairs in map into this Map. |
java.lang.Object |
remove(java.lang.Object key)
Removes the key, value pair from this Map. |
(package private) void |
removeEntry(AbstractHashMap.Entry doomed)
Removes the specified entry from this AbstractHashMap (and increments modCount). |
boolean |
sameContentsAs(Map c)
Returns true if this Collection's contents are equal to c's. |
boolean |
sameStateAs(HasState victem)
If two HasStates have the same internal state, return true. |
int |
size()
Returns the number of key-value pairs in this map. |
void |
sweepNulls()
Cleans out keys for null values. |
java.util.Iterator |
valueIterator()
Returns an iterator over the values. |
Methods inherited from class net.walend.collection.AbstractHashMap |
capacity, clone, getIdentitor, getPrincipleInterface, loadFactor, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.walend.collection.Map |
getIdentitor |
Methods inherited from interface net.walend.collection.HasState |
getPrincipleInterface |
Field Detail |
private final java.lang.Object guard
Constructor Detail |
public SoftHashMap()
public SoftHashMap(int capacity)
public SoftHashMap(int capacity, float loadFactor)
public SoftHashMap(Identitor identitor)
public SoftHashMap(Identitor identitor, int capacity)
public SoftHashMap(Identitor identitor, int capacity, float loadFactor)
public SoftHashMap(java.util.Map orig)
public SoftHashMap(Map orig)
Method Detail |
public boolean sameStateAs(HasState victem)
For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.
sameStateAs
in interface HasState
sameStateAs
in class AbstractHashMap
public int size()
This method calls sweepNulls(), and takes linear time.
size
in interface Map
size
in class AbstractHashMap
net.walend.collection.AbstractHashMap
public boolean isEmpty()
This method calls sweepNulls(), and takes linear time.
isEmpty
in interface Map
isEmpty
in class AbstractHashMap
net.walend.collection.AbstractHashMap
public boolean containsKey(java.lang.Object key)
containsKey
in interface Map
containsKey
in class AbstractHashMap
java.lang.NullPointerException
- if key is null.public boolean containsValue(java.lang.Object value)
containsValue
in interface Map
containsValue
in class AbstractHashMap
java.lang.NullPointerException
- if value is null.public java.lang.Object get(java.lang.Object key)
get
in interface Map
get
in class AbstractHashMap
java.lang.NullPointerException
- if the key is null.public Set getKeys()
getKeys
in interface Map
getKeys
in class AbstractHashMap
net.walend.collection.AbstractHashMap
public Collection getValues()
getValues
in interface Map
getValues
in class AbstractHashMap
net.walend.collection.AbstractHashMap
public java.util.Iterator keyIterator()
This method calls sweepNulls(), and takes linear time.
keyIterator
in interface Map
keyIterator
in class AbstractHashMap
public java.util.Iterator valueIterator()
This method calls sweepNulls(), and takes linear time.
valueIterator
in interface Map
valueIterator
in class AbstractHashMap
public boolean containsAll(Map c)
containsAll
in interface Map
containsAll
in class AbstractHashMap
public boolean sameContentsAs(Map c)
sameContentsAs
in interface Map
sameContentsAs
in class AbstractHashMap
public java.util.Map getJavaMap()
getJavaMap
in interface Map
getJavaMap
in class AbstractHashMap
void removeEntry(AbstractHashMap.Entry doomed)
AbstractHashMap
removeEntry
in class AbstractHashMap
public java.lang.Object put(java.lang.Object key, java.lang.Object value)
put
in interface MutableMap
put
in class AbstractHashMap
java.lang.NullPointerException
- if the key or value is null.public java.lang.Object remove(java.lang.Object key)
remove
in interface MutableMap
remove
in class AbstractHashMap
java.lang.NullPointerException
- if the key is null.public void putAll(Map map)
putAll
in interface MutableMap
putAll
in class AbstractHashMap
java.lang.NullPointerException
- if map is null.public void clear()
clear
in interface MutableMap
clear
in class AbstractHashMap
protected AbstractHashMap.Entry newEntry(int hash, java.lang.Object key, java.lang.Object value, AbstractHashMap.Entry next)
newEntry
in class AbstractHashMap
public void sweepNulls()
public final java.lang.Object getGuard()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |