Class WeakCache
java.lang.Object
java.util.AbstractMap
com.thoughtworks.xstream.core.util.WeakCache
- All Implemented Interfaces:
Map
A HashMap implementation with weak references values and by default for the key. When the
value is garbage collected, the key will also vanish from the map.
- Since:
- 1.4
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,
V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) protected Reference
createReference
(Object value) entrySet()
boolean
int
hashCode()
private Object
iterate
(WeakCache.Visitor visitor, int type) keySet()
int
size()
toString()
values()
Methods inherited from class java.util.AbstractMap
clone, isEmpty, putAll
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
Field Details
-
map
-
-
Constructor Details
-
WeakCache
public WeakCache()Construct a WeakCache with weak keys.Note, that the internally used WeakHashMap is not thread-safe.
- Parameters:
map
- the map to use- Since:
- 1.4
-
WeakCache
Construct a WeakCache.- Parameters:
map
- the map to use- Since:
- 1.4
-
-
Method Details
-
get
- Specified by:
get
in interfaceMap
- Overrides:
get
in classAbstractMap
-
put
- Specified by:
put
in interfaceMap
- Overrides:
put
in classAbstractMap
-
remove
- Specified by:
remove
in interfaceMap
- Overrides:
remove
in classAbstractMap
-
createReference
-
containsValue
- Specified by:
containsValue
in interfaceMap
- Overrides:
containsValue
in classAbstractMap
-
size
public int size()- Specified by:
size
in interfaceMap
- Overrides:
size
in classAbstractMap
-
values
- Specified by:
values
in interfaceMap
- Overrides:
values
in classAbstractMap
-
entrySet
- Specified by:
entrySet
in interfaceMap
- Specified by:
entrySet
in classAbstractMap
-
iterate
-
containsKey
- Specified by:
containsKey
in interfaceMap
- Overrides:
containsKey
in classAbstractMap
-
clear
public void clear()- Specified by:
clear
in interfaceMap
- Overrides:
clear
in classAbstractMap
-
keySet
- Specified by:
keySet
in interfaceMap
- Overrides:
keySet
in classAbstractMap
-
equals
- Specified by:
equals
in interfaceMap
- Overrides:
equals
in classAbstractMap
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceMap
- Overrides:
hashCode
in classAbstractMap
-
toString
- Overrides:
toString
in classAbstractMap
-