|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectAbstractMap<K,V>
WeakValueHashMap<K,V>
K
- The class of key elements.V
- The class of value elements.public class WeakValueHashMap<K,V>
A hashtable-based Map
implementation with weak values. An entry in a
WeakValueHashMap
will automatically be removed when its value is no longer
in ordinary use. This class is similar to the standard WeakHashMap
class provided in J2SE, except that weak references are hold on values instead of keys.
The WeakValueHashMap
class is thread-safe.
WeakHashMap
,
WeakHashSet
Constructor Summary | |
---|---|
WeakValueHashMap()
Creates a WeakValueHashMap . |
|
WeakValueHashMap(int initialSize)
Creates a WeakValueHashMap of the requested size and default load factor. |
|
WeakValueHashMap(Map<K,V> map)
Creates a new WeakValueHashMap populated with the contents of the provied map. |
Method Summary | |
---|---|
void |
clear()
Removes all of the elements from this map. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the specified key. |
boolean |
containsValue(Object value)
Returns true if this map maps one or more keys to this value. |
Set<Map.Entry<K,V>> |
entrySet()
Returns a set view of the mappings contained in this map. |
V |
get(Object key)
Returns the value to which this map maps the specified key. |
V |
put(K key,
V value)
Associates the specified value with the specified key in this map. |
V |
remove(Object key)
Removes the mapping for this key from this map if present. |
int |
size()
Returns the number of key-value mappings in this map. |
Methods inherited from class AbstractMap |
---|
clone, equals, hashCode, isEmpty, keySet, putAll, toString, values |
Methods inherited from class Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WeakValueHashMap()
WeakValueHashMap
.
public WeakValueHashMap(int initialSize)
WeakValueHashMap
of the requested size and default load factor.
initialSize
- The initial size.public WeakValueHashMap(Map<K,V> map)
WeakValueHashMap
populated with the contents of the provied map.
map
- Initial contents of the WeakValueHashMap
.Method Detail |
---|
public int size()
size
in interface Map<K,V>
size
in class AbstractMap<K,V>
public boolean containsValue(Object value)
true
if this map maps one or more keys to this value.
containsValue
in interface Map<K,V>
containsValue
in class AbstractMap<K,V>
value
- value whose presence in this map is to be tested.
true
if this map maps one or more keys to this value.public boolean containsKey(Object key)
true
if this map contains a mapping for the specified key.
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
key
- key whose presence in this map is to be tested.
true
if this map contains a mapping for the specified key.
NullPointerException
- If key is null
.public V get(Object key)
null
if the map contains no mapping for this key.
get
in interface Map<K,V>
get
in class AbstractMap<K,V>
key
- Key whose associated value is to be returned.
NullPointerException
- if the key is null
.public V put(K key, V value)
WeakReference
.
put
in interface Map<K,V>
put
in class AbstractMap<K,V>
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.
null
if there was no mapping for key.
NullPointerException
- if the key or the value is null
.public V remove(Object key)
remove
in interface Map<K,V>
remove
in class AbstractMap<K,V>
key
- key whose mapping is to be removed from the map.
null
if there was no entry for key.public void clear()
clear
in interface Map<K,V>
clear
in class AbstractMap<K,V>
public Set<Map.Entry<K,V>> entrySet()
Map.Entry
.
The current implementation thrown UnsupportedOperationException
.
entrySet
in interface Map<K,V>
entrySet
in class AbstractMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |