public class WeakHashMap<K, V>
- Object
- WeakHashMap
ImplementsMap<K, V>
Helper weak hash map substitute
Constructors
public WeakHashMap() |
Methods
public int size() | Returns the number of mappings in this Map. |
public boolean isEmpty() | Returns whether this map is empty. |
public boolean containsKey(Object key) | Returns whether this Map contains the specified key. |
public boolean containsValue(Object value) | This method is unsupported in the weak hash map |
public V get(Object key) | Returns the value of the mapping with the specified key. |
public V put(K key, V value) | Maps the specified key to the specified value. |
public V remove(Object key) | Removes a mapping with the specified key from this Map. |
public void putAll(Map<? extends K, ? extends V> m) | Copies every mapping in the specified Map to this Map. |
public void clear() | Removes all elements from this Map, leaving it empty. |
public Set<K> keySet() | Returns a set of the keys contained in this Map. |
public Collection<V> values() | Unsupported operation |
public Set<Map.Entry<K, V>> entrySet() | Unsupported operation |
Inherited nested types
Inherited methods
Constructor details
WeakHashMap
public WeakHashMap()Method details
size
public int size()Returns the number of mappings in this
Map.Returns
the number of mappings in this
Map.isEmpty
public boolean isEmpty()Returns whether this map is empty.
Returns
true if this map has no elements, false
otherwise.containsKey
public boolean containsKey(Object key)Returns whether this
Map contains the specified key.Parameters
keyObject- the key to search for.
Returns
true if this map contains the specified key,
false otherwise.containsValue
public boolean containsValue(Object value)This method is unsupported in the weak hash map
Parameters
valueObject- the value to search for.
Returns
true if this map contains the specified value,
false otherwise.get
public V get(Object key)Returns the value of the mapping with the specified key.
Parameters
keyObject- the key.
Returns
the value of the mapping with the specified key, or
null
if no mapping for the specified key is found.put
public V put(K key, V value)Maps the specified key to the specified value.
Parameters
keyK- the key.
valueV- the value.
Returns
the value of any previous mapping with the specified key or
null if there was no mapping.Throws
UnsupportedOperationException- if adding to this
Mapis not supported. ClassCastException- if the class of the key or value is inappropriate for
this
Map. IllegalArgumentException- if the key or value cannot be added to this
Map. NullPointerException- if the key or value is
nulland thisMapdoes not supportnullkeys or values.
remove
public V remove(Object key)Removes a mapping with the specified key from this
Map.Parameters
keyObject- the key of the mapping to remove.
Returns
the value of the removed mapping or
null if no mapping
for the specified key was found.Throws
UnsupportedOperationException- if removing from this
Mapis not supported.
putAll
public void putAll(Map<? extends K, ? extends V> m)Copies every mapping in the specified
Map to this Map.Parameters
mMap<? extends K, ? extends V>- the
Mapto copy mappings from.
Throws
UnsupportedOperationException- if adding to this
Mapis not supported. ClassCastException- if the class of a key or a value of the specified
Mapis inappropriate for thisMap. IllegalArgumentException- if a key or value cannot be added to this
Map. NullPointerException- if a key or value is
nulland thisMapdoes not supportnullkeys or values.
clear
public void clear()Removes all elements from this
Map, leaving it empty.Throws
UnsupportedOperationException- if removing elements from this
Mapis not supported.
keySet
public Set<K> keySet()Returns a set of the keys contained in this
Map. The Set is backed by
this Map so changes to one are reflected by the other. The Set does not
support adding.Returns
a set of the keys.
values
public Collection<V> values()Unsupported operation
Returns
a collection of the values contained in this map.
entrySet
public Set<Map.Entry<K, V>> entrySet()Unsupported operation
Returns
a set of the mappings