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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()computeIfPresent(K key, @NonNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanstatic voidEvictnumToEvictitems from the givenmapat random.voidforEach(BiConsumer<? super K, ? super V> action) getOrDefault(Object key, V defaultValue) inthashCode()voidputIfAbsent(K key, V value) booleanbooleanvoidreplaceAll(BiFunction<? super K, ? super V, ? extends V> function) intsize()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:
getOrDefaultin interfaceConcurrentMap<K,V> - Specified by:
getOrDefaultin interfaceMap<K,V>
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Overrides:
containsKeyin classAbstractMap<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Overrides:
containsValuein classAbstractMap<K,V>
-
size
public int size() -
clear
public void clear() -
putAll
-
remove
-
hashCode
public int hashCode() -
equals
-
toString
- Overrides:
toStringin classAbstractMap<K,V>
-
forEach
-
evict
EvictnumToEvictitems from the givenmapat 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:
replaceAllin interfaceConcurrentMap<K,V> - Specified by:
replaceAllin interfaceMap<K,V>
-
computeIfAbsent
- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, @NonNull @NonNull BiFunction<? super K, ? super V, ? extends V> remappingFunction) - Specified by:
computeIfPresentin interfaceConcurrentMap<K,V> - Specified by:
computeIfPresentin interfaceMap<K,V>
-
compute
-
merge
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
replace
-