- All Implemented Interfaces:
Map<K,V>
public class WeakKeyValueMap<K,V>
extends Object
implements Map<K,V>
HashMap with weak reference on both sides.
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
-
Field Summary
Fields
The internal delegate map.
-
Constructor Summary
Constructors
-
Method Summary
void
boolean
Returns if key is contained.
boolean
Returns if value is contained.
boolean
void
int
Returns the size of the map.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
content
The internal delegate map.
-
Constructor Details
-
WeakKeyValueMap
public WeakKeyValueMap()
-
WeakKeyValueMap
public WeakKeyValueMap(Map<? extends K,? extends V> m)
-
Method Details
-
size
public int size()
Returns the size of the map.
- Specified by:
size
in interface Map<K,V>
-
isEmpty
public boolean isEmpty()
Returns if empty.
- Specified by:
isEmpty
in interface Map<K,V>
-
containsKey
public boolean containsKey(Object key)
Returns if key is contained.
- Specified by:
containsKey
in interface Map<K,V>
-
containsValue
public boolean containsValue(Object value)
Returns if value is contained.
- Specified by:
containsValue
in interface Map<K,V>
-
get
Gets the value for key.
- Specified by:
get
in interface Map<K,V>
-
put
public V put(K key,
V value)
Adds value for key.
- Specified by:
put
in interface Map<K,V>
-
remove
Removes key.
- Specified by:
remove
in interface Map<K,V>
-
putAll
public void putAll(Map<? extends K,? extends V> m)
Adds other map content.
- Specified by:
putAll
in interface Map<K,V>
-
clear
public void clear()
Clears map.
- Specified by:
clear
in interface Map<K,V>
-
keySet
Returns the key set.
- Specified by:
keySet
in interface Map<K,V>
-
values
Returns the values.
- Specified by:
values
in interface Map<K,V>
-
entrySet
Returns the entry set.
- Specified by:
entrySet
in interface Map<K,V>