Package io.micronaut.core.util
Class CopyOnWriteMap<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
io.micronaut.core.util.CopyOnWriteMap<K,V>
- Type Parameters:
K
- The key typeV
- The value type
- All Implemented Interfaces:
ConcurrentMap<K,
,V> Map<K,
V>
@Internal
public final class CopyOnWriteMap<K,V>
extends AbstractMap<K,V>
implements ConcurrentMap<K,V>
Thread-safe map that is optimized for reads. Uses a normal
HashMap
that is copied on
update operations.-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
computeIfPresent
(K key, @NonNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
static void
EvictnumToEvict
items from the givenmap
at random.void
forEach
(BiConsumer<? super K, ? super V> action) getOrDefault
(Object key, V defaultValue) int
hashCode()
void
putIfAbsent
(K key, V value) boolean
boolean
void
replaceAll
(BiFunction<? super K, ? super V, ? extends V> function) int
size()
toString()
Methods inherited from class java.util.AbstractMap
clone, isEmpty, keySet, values
-
Constructor Details
-
CopyOnWriteMap
public CopyOnWriteMap(int maxSize)
-
-
Method Details
-
entrySet
-
get
-
getOrDefault
- Specified by:
getOrDefault
in interfaceConcurrentMap<K,
V> - Specified by:
getOrDefault
in interfaceMap<K,
V>
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V> - Overrides:
containsKey
in classAbstractMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V> - Overrides:
containsValue
in classAbstractMap<K,
V>
-
size
public int size() -
clear
public void clear() -
putAll
-
remove
-
hashCode
public int hashCode() -
equals
-
toString
- Overrides:
toString
in classAbstractMap<K,
V>
-
forEach
-
evict
EvictnumToEvict
items from the givenmap
at random. This is not an atomic operation.- Parameters:
map
- The map to modifynumToEvict
- The number of items to remove
-
put
-
remove
-
replace
-
replaceAll
- Specified by:
replaceAll
in interfaceConcurrentMap<K,
V> - Specified by:
replaceAll
in interfaceMap<K,
V>
-
computeIfAbsent
- Specified by:
computeIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
computeIfAbsent
in interfaceMap<K,
V>
-
computeIfPresent
public V computeIfPresent(K key, @NonNull @NonNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) - Specified by:
computeIfPresent
in interfaceConcurrentMap<K,
V> - Specified by:
computeIfPresent
in interfaceMap<K,
V>
-
compute
-
merge
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,
V> - Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
replace
-