Class ConcurrentHashMapUnsafe<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.ConcurrentHashMapUnsafe<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 class ConcurrentHashMapUnsafe<K,V> extends AbstractMutableMap<K,V> implements ConcurrentMutableMap<K,V>, Externalizable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ConcurrentHashMapUnsafe()
ConcurrentHashMapUnsafe(int initialCapacity)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
int
countEntries()
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>
ConcurrentHashMapUnsafe<K,V>newMap()
static <K,V>
ConcurrentHashMapUnsafe<K,V>newMap(int newSize)
static <NK,NV>
ConcurrentHashMapUnsafe<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>
VputIfAbsentGetIfPresent(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()
ConcurrentHashMapUnsafe<K,V>
withAllKeyValueArguments(Pair<? extends K,? extends V>... keyValues)
ConcurrentHashMapUnsafe<K,V>
withAllKeyValues(Iterable<? extends Pair<? extends K,? extends V>> keyValues)
ConcurrentHashMapUnsafe<K,V>
withKeyValue(K key, V value)
ConcurrentHashMapUnsafe<K,V>
withoutAllKeys(Iterable<? extends K> keys)
ConcurrentHashMapUnsafe<K,V>
withoutKey(K key)
void
writeExternal(ObjectOutput out)
-
Methods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMap
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, zipWithIndex
-
Methods inherited from class org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable
aggregateBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPutWithKey, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, valuesView
-
Methods 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, toArray
-
Methods 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, zipWithIndex
-
Methods inherited from interface java.util.concurrent.ConcurrentMap
compute, computeIfAbsent, computeIfPresent, merge, replaceAll
-
Methods inherited from interface org.eclipse.collections.api.map.ConcurrentMutableMap
forEach, getOrDefault, withMap, withMapIterable
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.map.MapIterable
detect, detectOptional, getIfAbsentValue, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, valuesView
-
Methods inherited from interface org.eclipse.collections.api.map.MutableMap
aggregateBy, 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, zipWithIndex
-
Methods inherited from interface org.eclipse.collections.api.map.MutableMapIterable
add, countBy, countByEach, countByWith, getIfAbsentPutWithKey, putAllMapIterable, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLong
-
Methods 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, 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
-
-
-
-
Method Detail
-
newMap
public static <K,V> ConcurrentHashMapUnsafe<K,V> newMap()
-
newMap
public static <K,V> ConcurrentHashMapUnsafe<K,V> newMap(int newSize)
-
putIfAbsent
public V putIfAbsent(K key, V value)
- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
putIfAbsent
in interfaceMap<K,V>
-
countEntries
public int countEntries()
-
getIfAbsentPut
public V getIfAbsentPut(K key, Function0<? extends V> factory)
- Specified by:
getIfAbsentPut
in interfaceMutableMapIterable<K,V>
- Overrides:
getIfAbsentPut
in classAbstractMutableMapIterable<K,V>
-
getIfAbsentPut
public V getIfAbsentPut(K key, V value)
- Specified by:
getIfAbsentPut
in interfaceMutableMapIterable<K,V>
- Overrides:
getIfAbsentPut
in 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.
-
size
public int size()
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceMap<K,V>
- Specified by:
isEmpty
in interfaceRichIterable<K>
- Overrides:
isEmpty
in classAbstractRichIterable<V>
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
- Specified by:
containsKey
in interfaceMapIterable<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
- Specified by:
containsValue
in interfaceMapIterable<K,V>
-
putAllInParallel
public void putAllInParallel(Map<? extends K,? extends V> map, int chunks, Executor executor)
-
parallelForEachKeyValue
public void parallelForEachKeyValue(List<Procedure2<K,V>> blocks, Executor executor)
-
parallelForEachValue
public void parallelForEachValue(List<Procedure<V>> blocks, Executor executor)
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object o)
-
toString
public String toString()
Description copied from class:AbstractRichIterable
Returns 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:
toString
in interfaceMapIterable<K,V>
- Specified by:
toString
in interfaceRichIterable<K>
- Overrides:
toString
in classAbstractRichIterable<V>
- Returns:
- a string representation of this collection.
- See Also:
AbstractCollection.toString()
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
ClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Throws:
IOException
-
newMap
public static <NK,NV> ConcurrentHashMapUnsafe<NK,NV> newMap(Map<NK,NV> map)
-
withKeyValue
public ConcurrentHashMapUnsafe<K,V> withKeyValue(K key, V value)
- Specified by:
withKeyValue
in interfaceMutableMap<K,V>
- Specified by:
withKeyValue
in interfaceMutableMapIterable<K,V>
- Overrides:
withKeyValue
in classAbstractMutableMap<K,V>
-
withAllKeyValues
public ConcurrentHashMapUnsafe<K,V> withAllKeyValues(Iterable<? extends Pair<? extends K,? extends V>> keyValues)
- Specified by:
withAllKeyValues
in interfaceMutableMap<K,V>
- Specified by:
withAllKeyValues
in interfaceMutableMapIterable<K,V>
- Overrides:
withAllKeyValues
in classAbstractMutableMap<K,V>
-
withAllKeyValueArguments
public ConcurrentHashMapUnsafe<K,V> withAllKeyValueArguments(Pair<? extends K,? extends V>... keyValues)
- Specified by:
withAllKeyValueArguments
in interfaceMutableMap<K,V>
- Specified by:
withAllKeyValueArguments
in interfaceMutableMapIterable<K,V>
- Overrides:
withAllKeyValueArguments
in classAbstractMutableMap<K,V>
-
withoutKey
public ConcurrentHashMapUnsafe<K,V> withoutKey(K key)
- Specified by:
withoutKey
in interfaceMutableMap<K,V>
- Specified by:
withoutKey
in interfaceMutableMapIterable<K,V>
- Overrides:
withoutKey
in classAbstractMutableMap<K,V>
-
withoutAllKeys
public ConcurrentHashMapUnsafe<K,V> withoutAllKeys(Iterable<? extends K> keys)
- Specified by:
withoutAllKeys
in interfaceMutableMap<K,V>
- Specified by:
withoutAllKeys
in interfaceMutableMapIterable<K,V>
- Overrides:
withoutAllKeys
in classAbstractMutableMap<K,V>
-
clone
public MutableMap<K,V> clone()
- Specified by:
clone
in interfaceMutableMap<K,V>
- Specified by:
clone
in classAbstractMutableMap<K,V>
-
newEmpty
public <K,V> MutableMap<K,V> newEmpty(int capacity)
Description copied from class:AbstractMutableMap
Creates a new instance of the same type, using the given capacity and the default growth parameters.- Specified by:
newEmpty
in classAbstractMutableMap<K,V>
-
notEmpty
public boolean notEmpty()
- Specified by:
notEmpty
in interfaceRichIterable<K>
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)
- Specified by:
forEachWithIndex
in interfaceInternalIterable<K>
- Overrides:
forEachWithIndex
in classAbstractMapIterable<K,V>
-
newEmpty
public MutableMap<K,V> newEmpty()
- Specified by:
newEmpty
in interfaceMutableMap<K,V>
- Specified by:
newEmpty
in interfaceMutableMapIterable<K,V>
-
tap
public ConcurrentMutableMap<K,V> tap(Procedure<? super V> procedure)
- Specified by:
tap
in interfaceConcurrentMutableMap<K,V>
- Specified by:
tap
in interfaceMapIterable<K,V>
- Specified by:
tap
in interfaceMutableMap<K,V>
- Specified by:
tap
in interfaceMutableMapIterable<K,V>
- Specified by:
tap
in interfaceRichIterable<K>
- Specified by:
tap
in interfaceUnsortedMapIterable<K,V>
- Overrides:
tap
in classAbstractMutableMap<K,V>
-
forEachValue
public void forEachValue(Procedure<? super V> procedure)
- Specified by:
forEachValue
in interfaceMapIterable<K,V>
- Overrides:
forEachValue
in classAbstractMapIterable<K,V>
-
forEachKey
public void forEachKey(Procedure<? super K> procedure)
- Specified by:
forEachKey
in interfaceMapIterable<K,V>
- Overrides:
forEachKey
in classAbstractMapIterable<K,V>
-
forEachKeyValue
public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
- Specified by:
forEachKeyValue
in 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:
collectKeysAndValues
in interfaceMutableMap<K,V>
-
getIfAbsentPutWith
public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
- Specified by:
getIfAbsentPutWith
in interfaceMutableMapIterable<K,V>
- Overrides:
getIfAbsentPutWith
in classAbstractMutableMapIterable<K,V>
-
getIfAbsent
public V getIfAbsent(K key, Function0<? extends V> function)
- Specified by:
getIfAbsent
in interfaceMapIterable<K,V>
- Overrides:
getIfAbsent
in classAbstractMapIterable<K,V>
-
getIfAbsentWith
public <P> V getIfAbsentWith(K key, Function<? super P,? extends V> function, P parameter)
- Specified by:
getIfAbsentWith
in interfaceMapIterable<K,V>
- Overrides:
getIfAbsentWith
in classAbstractMapIterable<K,V>
-
ifPresentApply
public <A> A ifPresentApply(K key, Function<? super V,? extends A> function)
- Specified by:
ifPresentApply
in interfaceMapIterable<K,V>
- Overrides:
ifPresentApply
in classAbstractMapIterable<K,V>
-
forEachWith
public <P> void forEachWith(Procedure2<? super V,? super P> procedure, P parameter)
- Specified by:
forEachWith
in interfaceInternalIterable<K>
- Overrides:
forEachWith
in classAbstractMapIterable<K,V>
-
updateValue
public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
- Specified by:
updateValue
in interfaceMutableMapIterable<K,V>
- Overrides:
updateValue
in 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:
updateValueWith
in interfaceMutableMapIterable<K,V>
- Overrides:
updateValueWith
in classAbstractMutableMapIterable<K,V>
-
toImmutable
public ImmutableMap<K,V> toImmutable()
- Specified by:
toImmutable
in interfaceMapIterable<K,V>
- Specified by:
toImmutable
in interfaceMutableMapIterable<K,V>
- Specified by:
toImmutable
in interfaceUnsortedMapIterable<K,V>
- Overrides:
toImmutable
in classAbstractMutableMap<K,V>
-
-