public final class ConcurrentHashMap<K,V> extends AbstractMutableMap<K,V> implements ConcurrentMutableMap<K,V>, Externalizable
| Constructor and Description |
|---|
ConcurrentHashMap() |
ConcurrentHashMap(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
MutableMap<K,V> |
clone() |
<E> MutableMap<K,V> |
collectKeysAndValues(Iterable<E> iterable,
Function<? super E,? extends K> keyFunction,
Function<? super E,? extends V> valueFunction) |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(Object o) |
void |
forEachKey(Procedure<? super K> procedure) |
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure) |
void |
forEachValue(Procedure<? super V> procedure) |
<P> void |
forEachWith(Procedure2<? super V,? super P> procedure,
P parameter) |
void |
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) |
V |
get(Object key) |
V |
getIfAbsent(K key,
Function0<? extends V> function) |
V |
getIfAbsentPut(K key,
Function<? super K,? extends V> factory) |
V |
getIfAbsentPut(K key,
Function0<? extends V> factory) |
V |
getIfAbsentPut(K key,
V value) |
<P> V |
getIfAbsentPutWith(K key,
Function<? super P,? extends V> function,
P parameter) |
<P> V |
getIfAbsentWith(K key,
Function<? super P,? extends V> function,
P parameter) |
int |
hashCode() |
<A> A |
ifPresentApply(K key,
Function<? super V,? extends A> function) |
boolean |
isEmpty() |
Iterator<V> |
iterator() |
Set<K> |
keySet() |
MutableMap<K,V> |
newEmpty() |
<K,V> MutableMap<K,V> |
newEmpty(int capacity)
Creates a new instance of the same type, using the given capacity and the default growth parameters.
|
static <K,V> ConcurrentHashMap<K,V> |
newMap() |
static <K,V> ConcurrentHashMap<K,V> |
newMap(int newSize) |
static <NK,NV> ConcurrentHashMap<NK,NV> |
newMap(Map<NK,NV> map) |
boolean |
notEmpty() |
void |
parallelForEachKeyValue(List<Procedure2<K,V>> blocks,
Executor executor) |
void |
parallelForEachValue(List<Procedure<V>> blocks,
Executor executor) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> map) |
void |
putAllInParallel(Map<? extends K,? extends V> map,
int chunks,
Executor executor) |
V |
putIfAbsent(K key,
V value) |
<P1,P2> V |
putIfAbsentGetIfPresent(K key,
Function2<? super K,? super V,? extends K> keyTransformer,
Function3<P1,P2,? super K,? extends V> factory,
P1 param1,
P2 param2)
It puts an object into the map based on the key.
|
void |
readExternal(ObjectInput in) |
V |
remove(Object key) |
boolean |
remove(Object key,
Object value) |
V |
removeKey(K key) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
int |
size() |
ConcurrentMutableMap<K,V> |
tap(Procedure<? super V> procedure) |
ImmutableMap<K,V> |
toImmutable() |
String |
toString()
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
V |
updateValue(K key,
Function0<? extends V> factory,
Function<? super V,? extends V> function) |
<P> V |
updateValueWith(K key,
Function0<? extends V> factory,
Function2<? super V,? super P,? extends V> function,
P parameter) |
Collection<V> |
values() |
ConcurrentHashMap<K,V> |
withAllKeyValueArguments(Pair<? extends K,? extends V>... keyValues) |
ConcurrentHashMap<K,V> |
withAllKeyValues(Iterable<? extends Pair<? extends K,? extends V>> keyValues) |
ConcurrentHashMap<K,V> |
withKeyValue(K key,
V value) |
ConcurrentHashMap<K,V> |
withMap(Map<? extends K,? extends V> map) |
ConcurrentHashMap<K,V> |
withMapIterable(MapIterable<? extends K,? extends V> mapIterable) |
ConcurrentHashMap<K,V> |
withoutAllKeys(Iterable<? extends K> keys) |
ConcurrentHashMap<K,V> |
withoutKey(K key) |
void |
writeExternal(ObjectOutput out) |
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, zip, zipWithIndexaggregateBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPutWithKey, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesViewallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, getFirst, getIfAbsentValue, getLast, getOnly, getOrDefault, noneSatisfy, noneSatisfyWith, toArray, toArrayappendString, appendString, collect, collectIf, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexgetOrDefaultaggregateBy, aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flatCollectWith, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, zip, zipWithIndexadd, countBy, countByEach, countByWith, getIfAbsentPutWithKey, putAllMapIterable, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLongcompute, computeIfAbsent, computeIfPresent, forEach, merge, replaceAlldetect, detectOptional, getIfAbsentValue, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewaggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEachcompute, computeIfAbsent, computeIfPresent, forEach, merge, replaceAllpublic ConcurrentHashMap()
public ConcurrentHashMap(int initialCapacity)
public static <K,V> ConcurrentHashMap<K,V> newMap()
public static <K,V> ConcurrentHashMap<K,V> newMap(int newSize)
public V putIfAbsent(K key, V value)
putIfAbsent in interface ConcurrentMap<K,V>putIfAbsent in interface Map<K,V>public V getIfAbsentPut(K key, Function0<? extends V> factory)
getIfAbsentPut in interface MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public V getIfAbsentPut(K key, V value)
getIfAbsentPut in interface MutableMapIterable<K,V>getIfAbsentPut in class AbstractMutableMapIterable<K,V>public <P1,P2> V putIfAbsentGetIfPresent(K key, Function2<? super K,? super V,? extends K> keyTransformer, Function3<P1,P2,? super K,? extends V> factory, P1 param1, P2 param2)
key - The "mutable" key, which has the same identity/hashcode as the inserted key, only during this callkeyTransformer - If the record is absent, the transformer will transform the "mutable" key into an immutable copy of the key.
Note that the transformed key must have the same identity/hashcode as the original "mutable" key.factory - It creates an object, if it is not present in the map already.public int size()
public boolean isEmpty()
isEmpty in interface Map<K,V>isEmpty in interface RichIterable<V>isEmpty in class AbstractRichIterable<V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in interface MapIterable<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in interface MapIterable<K,V>public void putAllInParallel(Map<? extends K,? extends V> map, int chunks, Executor executor)
public void parallelForEachKeyValue(List<Procedure2<K,V>> blocks, Executor executor)
public int hashCode()
public boolean equals(Object o)
public String toString()
AbstractRichIterable
Assert.assertEquals("[]", Lists.mutable.empty().toString());
Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
toString in interface MapIterable<K,V>toString in interface RichIterable<V>toString in class AbstractRichIterable<V>AbstractCollection.toString()public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic static <NK,NV> ConcurrentHashMap<NK,NV> newMap(Map<NK,NV> map)
public ConcurrentHashMap<K,V> withKeyValue(K key, V value)
withKeyValue in interface MutableMap<K,V>withKeyValue in interface MutableMapIterable<K,V>withKeyValue in class AbstractMutableMap<K,V>public ConcurrentHashMap<K,V> withMap(Map<? extends K,? extends V> map)
withMap in interface ConcurrentMutableMap<K,V>withMap in interface MutableMap<K,V>withMap in interface MutableMapIterable<K,V>public ConcurrentHashMap<K,V> withMapIterable(MapIterable<? extends K,? extends V> mapIterable)
withMapIterable in interface ConcurrentMutableMap<K,V>withMapIterable in interface MutableMap<K,V>withMapIterable in interface MutableMapIterable<K,V>public ConcurrentHashMap<K,V> withAllKeyValues(Iterable<? extends Pair<? extends K,? extends V>> keyValues)
withAllKeyValues in interface MutableMap<K,V>withAllKeyValues in interface MutableMapIterable<K,V>withAllKeyValues in class AbstractMutableMap<K,V>public ConcurrentHashMap<K,V> withAllKeyValueArguments(Pair<? extends K,? extends V>... keyValues)
withAllKeyValueArguments in interface MutableMap<K,V>withAllKeyValueArguments in interface MutableMapIterable<K,V>withAllKeyValueArguments in class AbstractMutableMap<K,V>public ConcurrentHashMap<K,V> withoutKey(K key)
withoutKey in interface MutableMap<K,V>withoutKey in interface MutableMapIterable<K,V>withoutKey in class AbstractMutableMap<K,V>public ConcurrentHashMap<K,V> withoutAllKeys(Iterable<? extends K> keys)
withoutAllKeys in interface MutableMap<K,V>withoutAllKeys in interface MutableMapIterable<K,V>withoutAllKeys in class AbstractMutableMap<K,V>public MutableMap<K,V> clone()
clone in interface MutableMap<K,V>clone in class AbstractMutableMap<K,V>public <K,V> MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>public boolean notEmpty()
notEmpty in interface RichIterable<V>public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)
forEachWithIndex in interface InternalIterable<V>forEachWithIndex in class AbstractMapIterable<K,V>public MutableMap<K,V> newEmpty()
newEmpty in interface MutableMap<K,V>newEmpty in interface MutableMapIterable<K,V>public ConcurrentMutableMap<K,V> tap(Procedure<? super V> procedure)
tap in interface ConcurrentMutableMap<K,V>tap in interface MapIterable<K,V>tap in interface MutableMap<K,V>tap in interface MutableMapIterable<K,V>tap in interface UnsortedMapIterable<K,V>tap in interface RichIterable<V>tap in class AbstractMutableMap<K,V>public void forEachValue(Procedure<? super V> procedure)
forEachValue in interface MapIterable<K,V>forEachValue in class AbstractMapIterable<K,V>public void forEachKey(Procedure<? super K> procedure)
forEachKey in interface MapIterable<K,V>forEachKey in class AbstractMapIterable<K,V>public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
forEachKeyValue in interface MapIterable<K,V>public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E,? extends K> keyFunction, Function<? super E,? extends V> valueFunction)
collectKeysAndValues in interface MutableMap<K,V>public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
getIfAbsentPutWith in interface MutableMapIterable<K,V>getIfAbsentPutWith in class AbstractMutableMapIterable<K,V>public V getIfAbsent(K key, Function0<? extends V> function)
getIfAbsent in interface MapIterable<K,V>getIfAbsent in class AbstractMapIterable<K,V>public <P> V getIfAbsentWith(K key, Function<? super P,? extends V> function, P parameter)
getIfAbsentWith in interface MapIterable<K,V>getIfAbsentWith in class AbstractMapIterable<K,V>public <A> A ifPresentApply(K key, Function<? super V,? extends A> function)
ifPresentApply in interface MapIterable<K,V>ifPresentApply in class AbstractMapIterable<K,V>public <P> void forEachWith(Procedure2<? super V,? super P> procedure, P parameter)
forEachWith in interface InternalIterable<V>forEachWith in class AbstractMapIterable<K,V>public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
updateValue in interface MutableMapIterable<K,V>updateValue in class AbstractMutableMapIterable<K,V>public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)
updateValueWith in interface MutableMapIterable<K,V>updateValueWith in class AbstractMutableMapIterable<K,V>public ImmutableMap<K,V> toImmutable()
toImmutable in interface MapIterable<K,V>toImmutable in interface MutableMapIterable<K,V>toImmutable in interface UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>Copyright © 2004–2022. All rights reserved.