Class ConcurrentHashMap<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMap<K,V>
org.eclipse.collections.impl.map.mutable.ConcurrentHashMap<K,V>
- All Implemented Interfaces:
Externalizable,Serializable,Cloneable,Iterable<V>,ConcurrentMap<K,,V> Map<K,,V> InternalIterable<V>,ConcurrentMutableMap<K,,V> MapIterable<K,,V> MutableMap<K,,V> MutableMapIterable<K,,V> UnsortedMapIterable<K,,V> RichIterable<V>
public final class ConcurrentHashMap<K,V>
extends AbstractMutableMap<K,V>
implements ConcurrentMutableMap<K,V>, Externalizable
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()MutableMap<K,V> clone()<E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction) booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanvoidforEachKey(Procedure<? super K> procedure) voidforEachKeyValue(Procedure2<? super K, ? super V> procedure) voidforEachValue(Procedure<? super V> procedure) <P> voidforEachWith(Procedure2<? super V, ? super P> procedure, P parameter) voidforEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) getIfAbsent(K key, Function0<? extends V> function) getIfAbsentPut(K key, Function<? super K, ? extends V> factory) getIfAbsentPut(K key, Function0<? extends V> factory) getIfAbsentPut(K key, V value) <P> VgetIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter) <P> VgetIfAbsentWith(K key, Function<? super P, ? extends V> function, P parameter) inthashCode()<A> AifPresentApply(K key, Function<? super V, ? extends A> function) booleanisEmpty()iterator()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> booleannotEmpty()voidparallelForEachKeyValue(List<Procedure2<K, V>> blocks, Executor executor) voidparallelForEachValue(List<Procedure<V>> blocks, Executor executor) voidvoidputAllInParallel(Map<? extends K, ? extends V> map, int chunks, Executor executor) 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.voidbooleanbooleanintsize()toString()Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.<P> VupdateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter) values()withAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValues) withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) withKeyValue(K key, V value) withMapIterable(MapIterable<? extends K, ? extends V> mapIterable) withoutAllKeys(Iterable<? extends K> keys) withoutKey(K key) voidMethods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMap
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectKeysUnique, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, replaceAll, select, select, selectInstancesOf, selectWith, zip, zipWithIndexMethods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable
aggregateBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPutWithKey, keysView, keyValuesView, reduceBy, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesViewMethods inherited from class org.eclipse.collections.impl.map.AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, getFirst, getIfAbsentValue, getLast, getOnly, getOrDefault, noneSatisfy, noneSatisfyWith, toArray, toArrayMethods inherited from class org.eclipse.collections.impl.AbstractRichIterable
appendString, 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, zipWithIndexMethods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, replaceAllMethods inherited from interface org.eclipse.collections.api.map.ConcurrentMutableMap
forEach, getOrDefaultMethods inherited from interface org.eclipse.collections.api.InternalIterable
forEachMethods inherited from interface org.eclipse.collections.api.map.MapIterable
detect, detectOptional, getIfAbsentValue, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewMethods inherited from interface org.eclipse.collections.api.map.MutableMap
aggregateBy, aggregateBy, aggregateInPlaceBy, asSynchronized, asUnmodifiable, collect, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectKeysUnique, collectLong, collectShort, collectValues, collectWith, flatCollect, flatCollectWith, flip, flipUniqueValues, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reduceBy, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, zip, zipWithIndexMethods inherited from interface org.eclipse.collections.api.map.MutableMapIterable
add, countBy, countByEach, countByWith, getIfAbsentPutWithKey, putAllMapIterable, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLongMethods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, 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, reduceBy, 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, zipWithIndex
-
Constructor Details
-
ConcurrentHashMap
public ConcurrentHashMap() -
ConcurrentHashMap
public ConcurrentHashMap(int initialCapacity)
-
-
Method Details
-
newMap
-
newMap
-
putIfAbsent
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V> - Specified by:
putIfAbsentin interfaceMap<K,V>
-
getIfAbsentPut
-
getIfAbsentPut
- Specified by:
getIfAbsentPutin interfaceMutableMapIterable<K,V> - Overrides:
getIfAbsentPutin classAbstractMutableMapIterable<K,V>
-
getIfAbsentPut
- Specified by:
getIfAbsentPutin interfaceMutableMapIterable<K,V> - Overrides:
getIfAbsentPutin classAbstractMutableMapIterable<K,V>
-
putIfAbsentGetIfPresent
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) It puts an object into the map based on the key. It uses a copy of the key converted by transformer.- Parameters:
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.
-
remove
-
size
public int size() -
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceMap<K,V> - Specified by:
isEmptyin interfaceRichIterable<K>- Overrides:
isEmptyin classAbstractRichIterable<V>
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Specified by:
containsKeyin interfaceMapIterable<K,V>
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Specified by:
containsValuein interfaceMapIterable<K,V>
-
get
-
put
-
putAllInParallel
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
replace
-
replace
-
remove
-
parallelForEachKeyValue
-
parallelForEachValue
-
hashCode
public int hashCode() -
equals
-
toString
Description copied from class:AbstractRichIterableReturns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.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());- Specified by:
toStringin interfaceMapIterable<K,V> - Specified by:
toStringin interfaceRichIterable<K>- Overrides:
toStringin classAbstractRichIterable<V>- Returns:
- a string representation of this collection.
- See Also:
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
newMap
-
withKeyValue
- Specified by:
withKeyValuein interfaceMutableMap<K,V> - Specified by:
withKeyValuein interfaceMutableMapIterable<K,V> - Overrides:
withKeyValuein classAbstractMutableMap<K,V>
-
withMap
- Specified by:
withMapin interfaceConcurrentMutableMap<K,V> - Specified by:
withMapin interfaceMutableMap<K,V> - Specified by:
withMapin interfaceMutableMapIterable<K,V>
-
withMapIterable
- Specified by:
withMapIterablein interfaceConcurrentMutableMap<K,V> - Specified by:
withMapIterablein interfaceMutableMap<K,V> - Specified by:
withMapIterablein interfaceMutableMapIterable<K,V>
-
withAllKeyValues
public ConcurrentHashMap<K,V> withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) - Specified by:
withAllKeyValuesin interfaceMutableMap<K,V> - Specified by:
withAllKeyValuesin interfaceMutableMapIterable<K,V> - Overrides:
withAllKeyValuesin classAbstractMutableMap<K,V>
-
withAllKeyValueArguments
- Specified by:
withAllKeyValueArgumentsin interfaceMutableMap<K,V> - Specified by:
withAllKeyValueArgumentsin interfaceMutableMapIterable<K,V> - Overrides:
withAllKeyValueArgumentsin classAbstractMutableMap<K,V>
-
withoutKey
- Specified by:
withoutKeyin interfaceMutableMap<K,V> - Specified by:
withoutKeyin interfaceMutableMapIterable<K,V> - Overrides:
withoutKeyin classAbstractMutableMap<K,V>
-
withoutAllKeys
- Specified by:
withoutAllKeysin interfaceMutableMap<K,V> - Specified by:
withoutAllKeysin interfaceMutableMapIterable<K,V> - Overrides:
withoutAllKeysin classAbstractMutableMap<K,V>
-
clone
- Specified by:
clonein interfaceMutableMap<K,V> - Specified by:
clonein classAbstractMutableMap<K,V>
-
newEmpty
Description copied from class:AbstractMutableMapCreates a new instance of the same type, using the given capacity and the default growth parameters.- Specified by:
newEmptyin classAbstractMutableMap<K,V>
-
notEmpty
public boolean notEmpty()- Specified by:
notEmptyin interfaceRichIterable<K>
-
forEachWithIndex
- Specified by:
forEachWithIndexin interfaceInternalIterable<K>- Overrides:
forEachWithIndexin classAbstractMapIterable<K,V>
-
iterator
-
newEmpty
- Specified by:
newEmptyin interfaceMutableMap<K,V> - Specified by:
newEmptyin interfaceMutableMapIterable<K,V>
-
tap
- Specified by:
tapin interfaceConcurrentMutableMap<K,V> - Specified by:
tapin interfaceMapIterable<K,V> - Specified by:
tapin interfaceMutableMap<K,V> - Specified by:
tapin interfaceMutableMapIterable<K,V> - Specified by:
tapin interfaceRichIterable<K>- Specified by:
tapin interfaceUnsortedMapIterable<K,V> - Overrides:
tapin classAbstractMutableMap<K,V>
-
forEachValue
- Specified by:
forEachValuein interfaceMapIterable<K,V> - Overrides:
forEachValuein classAbstractMapIterable<K,V>
-
forEachKey
- Specified by:
forEachKeyin interfaceMapIterable<K,V> - Overrides:
forEachKeyin classAbstractMapIterable<K,V>
-
forEachKeyValue
- Specified by:
forEachKeyValuein interfaceMapIterable<K,V>
-
collectKeysAndValues
public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction) - Specified by:
collectKeysAndValuesin interfaceMutableMap<K,V>
-
removeKey
- Specified by:
removeKeyin interfaceMutableMapIterable<K,V>
-
getIfAbsentPutWith
- Specified by:
getIfAbsentPutWithin interfaceMutableMapIterable<K,V> - Overrides:
getIfAbsentPutWithin classAbstractMutableMapIterable<K,V>
-
getIfAbsent
- Specified by:
getIfAbsentin interfaceMapIterable<K,V> - Overrides:
getIfAbsentin classAbstractMapIterable<K,V>
-
getIfAbsentWith
- Specified by:
getIfAbsentWithin interfaceMapIterable<K,V> - Overrides:
getIfAbsentWithin classAbstractMapIterable<K,V>
-
ifPresentApply
- Specified by:
ifPresentApplyin interfaceMapIterable<K,V> - Overrides:
ifPresentApplyin classAbstractMapIterable<K,V>
-
forEachWith
- Specified by:
forEachWithin interfaceInternalIterable<K>- Overrides:
forEachWithin classAbstractMapIterable<K,V>
-
updateValue
public V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function) - Specified by:
updateValuein interfaceMutableMapIterable<K,V> - Overrides:
updateValuein classAbstractMutableMapIterable<K,V>
-
updateValueWith
public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter) - Specified by:
updateValueWithin interfaceMutableMapIterable<K,V> - Overrides:
updateValueWithin classAbstractMutableMapIterable<K,V>
-
merge
-
toImmutable
- Specified by:
toImmutablein interfaceMapIterable<K,V> - Specified by:
toImmutablein interfaceMutableMapIterable<K,V> - Specified by:
toImmutablein interfaceUnsortedMapIterable<K,V> - Overrides:
toImmutablein classAbstractMutableMap<K,V>
-