Class ReferenceMap<K,V> 
- All Implemented Interfaces:
- Serializable,- Map<K,- V> 
- Direct Known Subclasses:
- ReferenceCache
The concurrent semantics of ConcurrentHashMap combined with the
 fact that the garbage collector can asynchronously reclaim and clean up
 after keys and values at any time can lead to some racy semantics. For
 example, size() returns an upper bound on the size, i.e. the actual
 size may be smaller in cases where the key or value has been reclaimed but
 the map entry has not been cleaned up yet.
Another example: If get(Object) cannot find an existing entry
 for a key, it will try to create one. This operation is not atomic. One
 thread could put(Object, Object) a value between the time another
 thread running get() checks for an entry and decides to create one.
 In this case, the newly created value will replace the put value in the
 map. Also, two threads running get() concurrently can potentially
 create duplicate values for a given key.
In other words, this class is great for caching but not atomicity.
- Author:
- crazybob@google.com (Bob Lee)
- See Also:
- 
Nested Class SummaryNested Classes
- 
Constructor SummaryConstructorsConstructorDescriptionReferenceMap(ReferenceType keyReferenceType, ReferenceType valueReferenceType) Concurrent hash map that wraps keys and/or values based on specified reference types.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()Returns an unmodifiable set view of the entries in this map.protected org.apache.struts2.inject.util.ReferenceMap.PutStrategybooleanisEmpty()keySet()Returns an unmodifiable set view of the keys in this map.voidputIfAbsent(K key, V value) protected ReferenceMap.Strategyprotected ReferenceMap.Strategybooleanbooleanprotected ReferenceMap.Strategyintsize()values()Returns an unmodifiable set view of the values in this map.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Mapcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, replaceAll
- 
Constructor Details- 
ReferenceMapConcurrent hash map that wraps keys and/or values based on specified reference types.- Parameters:
- keyReferenceType- key reference type
- valueReferenceType- value reference type
 
 
- 
- 
Method Details- 
get
- 
put
- 
remove
- 
sizepublic int size()
- 
isEmptypublic boolean isEmpty()
- 
containsKey- Specified by:
- containsKeyin interface- Map<K,- V> 
 
- 
containsValue- Specified by:
- containsValuein interface- Map<K,- V> 
 
- 
putAll
- 
clearpublic void clear()
- 
keySetReturns an unmodifiable set view of the keys in this map. As this method creates a defensive copy, the performance is O(n).
- 
valuesReturns an unmodifiable set view of the values in this map. As this method creates a defensive copy, the performance is O(n).
- 
putIfAbsent- Specified by:
- putIfAbsentin interface- Map<K,- V> 
 
- 
remove
- 
replace
- 
replace
- 
entrySetReturns an unmodifiable set view of the entries in this map. As this method creates a defensive copy, the performance is O(n).
- 
putStrategy
- 
putIfAbsentStrategy
- 
replaceStrategy
- 
getPutStrategyprotected org.apache.struts2.inject.util.ReferenceMap.PutStrategy getPutStrategy()
 
-