Top Description Methods
org.eclipse.collections.api.map

public Interface MutableMap<K, V>

extends MutableMapIterable<K, V>, UnsortedMapIterable<K, V>, Cloneable
Known Direct Subinterfaces
org.eclipse.collections.api.map.ConcurrentMutableMap, org.eclipse.collections.api.map.FixedSizeMap
Imports
java.util.Map, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.bag.primitive.MutableBooleanBag, .MutableByteBag, .MutableCharBag, .MutableDoubleBag, .MutableFloatBag, .MutableIntBag, .MutableLongBag, .MutableShortBag, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.factory.Maps, org.eclipse.collections.api.multimap.bag.MutableBagMultimap, org.eclipse.collections.api.multimap.set.MutableSetMultimap, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.partition.bag.PartitionMutableBag, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.api.tuple.Pair

A MutableMap is similar to a JCF Map but adds additional useful internal iterator methods. The MutableMap interface additionally implements some methods in the Smalltalk Dictionary protocol.

Method Summary

Modifier and TypeMethod and Description
public default <KK, VV> MutableMap<KK, VV>
aggregateBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super V, ? extends VV> nonMutatingAggregator)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.aggregateBy, org.eclipse.collections.api.RichIterable.aggregateBy.

Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.

public default <K1, V1, V2> MutableMap<K1, V2>
aggregateBy(Function<? super K, ? extends K1> keyFunction, Function<? super V, ? extends V1> valueFunction, Function0<? extends V2> zeroValueFactory, Function2<? super V2, ? super V1, ? extends V2> nonMutatingAggregator)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.aggregateBy, org.eclipse.collections.api.map.MapIterable.aggregateBy.

Applies an aggregate function over the map grouping results into a map based on the specific key and value groupBy functions.

public default <KK, VV> MutableMap<KK, VV>
aggregateInPlaceBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Procedure2<? super VV, ? super V> mutatingAggregator)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.aggregateInPlaceBy, org.eclipse.collections.api.RichIterable.aggregateInPlaceBy.

Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.

public MutableMap<K, V>
asSynchronized()

Redeclares org.eclipse.collections.api.map.MutableMapIterable.asSynchronized.

Returns a synchronized wrapper backed by this map.

public MutableMap<K, V>
asUnmodifiable()

Redeclares org.eclipse.collections.api.map.MutableMapIterable.asUnmodifiable.

Returns an unmodifiable view of this map.

public MutableMap<K, V>
public <K2, V2> MutableMap<K2, V2>
collect(Function2<? super K, ? super V, Pair<K2, V2>> function)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.collect, org.eclipse.collections.api.map.UnsortedMapIterable.collect.

For each key and value of the map the function is evaluated.

public <R> MutableBag<R>
collect(Function<? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.RichIterable.collect, org.eclipse.collections.api.map.UnsortedMapIterable.collect.

Returns a new collection with the results of applying the specified function on each element of the source collection.

public MutableBooleanBag
collectBoolean(BooleanFunction<? super V> booleanFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectBoolean, org.eclipse.collections.api.map.UnsortedMapIterable.collectBoolean.

Returns a new primitive boolean iterable with the results of applying the specified function on each element of the source collection.

public MutableByteBag
collectByte(ByteFunction<? super V> byteFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectByte, org.eclipse.collections.api.map.UnsortedMapIterable.collectByte.

Returns a new primitive byte iterable with the results of applying the specified function on each element of the source collection.

public MutableCharBag
collectChar(CharFunction<? super V> charFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectChar, org.eclipse.collections.api.map.UnsortedMapIterable.collectChar.

Returns a new primitive char iterable with the results of applying the specified function on each element of the source collection.

public MutableDoubleBag
collectDouble(DoubleFunction<? super V> doubleFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectDouble, org.eclipse.collections.api.map.UnsortedMapIterable.collectDouble.

Returns a new primitive double iterable with the results of applying the specified function on each element of the source collection.

public MutableFloatBag
collectFloat(FloatFunction<? super V> floatFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectFloat, org.eclipse.collections.api.map.UnsortedMapIterable.collectFloat.

Returns a new primitive float iterable with the results of applying the specified function on each element of the source collection.

public <R> MutableBag<R>
collectIf(Predicate<? super V> predicate, Function<? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf, org.eclipse.collections.api.map.UnsortedMapIterable.collectIf.

Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.

public MutableIntBag
collectInt(IntFunction<? super V> intFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectInt, org.eclipse.collections.api.map.UnsortedMapIterable.collectInt.

Returns a new primitive int iterable with the results of applying the specified function on each element of the source collection.

public <E> MutableMap<K, V>
collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction)

Adds all the entries derived from iterable to this.

public <R> MutableMap<R, V>
collectKeysUnique(Function2<? super K, ? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.collectKeysUnique, org.eclipse.collections.api.map.MapIterable.collectKeysUnique.

For each key and value of the map the function is evaluated.

public MutableLongBag
collectLong(LongFunction<? super V> longFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectLong, org.eclipse.collections.api.map.UnsortedMapIterable.collectLong.

Returns a new primitive long iterable with the results of applying the specified function on each element of the source collection.

public MutableShortBag
collectShort(ShortFunction<? super V> shortFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectShort, org.eclipse.collections.api.map.UnsortedMapIterable.collectShort.

Returns a new primitive short iterable with the results of applying the specified function on each element of the source collection.

public <R> MutableMap<K, R>
collectValues(Function2<? super K, ? super V, ? extends R> function)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.collectValues, org.eclipse.collections.api.map.UnsortedMapIterable.collectValues.

For each key and value of the map the function is evaluated.

public <P, V1> MutableBag<V1>
collectWith(Function2<? super V, ? super P, ? extends V1> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith, org.eclipse.collections.api.map.UnsortedMapIterable.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public <R> MutableBag<R>
public default <P, R> MutableBag<R>
flatCollectWith(Function2<? super V, ? super P, ? extends Iterable<R>> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectWith, org.eclipse.collections.api.map.UnsortedMapIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public MutableSetMultimap<V, K>
flip()

Redeclares org.eclipse.collections.api.map.MutableMapIterable.flip, org.eclipse.collections.api.map.UnsortedMapIterable.flip.

Given a map from Domain -> Range return a multimap from Range -> Domain.

public MutableMap<V, K>
flipUniqueValues()

Redeclares org.eclipse.collections.api.map.MutableMapIterable.flipUniqueValues, org.eclipse.collections.api.map.UnsortedMapIterable.flipUniqueValues.

Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.

public <VV> MutableBagMultimap<VV, V>
groupBy(Function<? super V, ? extends VV> function)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.groupBy, org.eclipse.collections.api.map.UnsortedMapIterable.groupBy.

For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable.

public <VV> MutableBagMultimap<VV, V>
groupByEach(Function<? super V, ? extends Iterable<VV>> function)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.groupByEach, org.eclipse.collections.api.map.UnsortedMapIterable.groupByEach.

Similar to groupBy(Function), except the result of evaluating function will return a collection of keys for each value.

public default <V1> MutableMap<V1, V>
groupByUniqueKey(Function<? super V, ? extends V1> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.groupByUniqueKey, org.eclipse.collections.api.map.UnsortedMapIterable.groupByUniqueKey.

For each element of the iterable, the function is evaluated, and the results of these evaluations are collected into a new map, where the transformed value is the key.

public MutableMap<K, V>
newEmpty()

Redeclares org.eclipse.collections.api.map.MutableMapIterable.newEmpty.

Creates a new instance of the same type, using the default capacity and growth parameters.

public PartitionMutableBag<V>
partition(Predicate<? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.partition, org.eclipse.collections.api.map.UnsortedMapIterable.partition.

Filters a collection into a PartitionedIterable based on the evaluation of the predicate.

public <P> PartitionMutableBag<V>
partitionWith(Predicate2<? super V, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.partitionWith, org.eclipse.collections.api.map.UnsortedMapIterable.partitionWith.

Filters a collection into a PartitionIterable based on the evaluation of the predicate.

public default <KK> MutableMap<KK, V>
reduceBy(Function<? super V, ? extends KK> groupBy, Function2<? super V, ? super V, ? extends V> reduceFunction)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.reduceBy, org.eclipse.collections.api.RichIterable.reduceBy.

Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.

public MutableMap<K, V>
reject(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.reject, org.eclipse.collections.api.map.UnsortedMapIterable.reject.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.

public MutableBag<V>
reject(Predicate<? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.reject, org.eclipse.collections.api.map.UnsortedMapIterable.reject.

Returns all elements of the source collection that return false when evaluating of the predicate.

public <P> MutableBag<V>
rejectWith(Predicate2<? super V, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.rejectWith, org.eclipse.collections.api.map.UnsortedMapIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public MutableMap<K, V>
select(Predicate2<? super K, ? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.select, org.eclipse.collections.api.map.UnsortedMapIterable.select.

For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.

public MutableBag<V>
select(Predicate<? super V> predicate)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.select, org.eclipse.collections.api.map.UnsortedMapIterable.select.

Returns all elements of the source collection that return true when evaluating the predicate.

public <S> MutableBag<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.selectInstancesOf, org.eclipse.collections.api.map.UnsortedMapIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public <P> MutableBag<V>
selectWith(Predicate2<? super V, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.selectWith, org.eclipse.collections.api.map.UnsortedMapIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public MutableMap<K, V>
tap(Procedure<? super V> procedure)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.tap, org.eclipse.collections.api.map.UnsortedMapIterable.tap.

Executes the Procedure for each value of the map and returns this.

public MutableMap<K, V>
withAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValueArguments.

Convenience var-args version of withAllKeyValues

public MutableMap<K, V>
withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.withAllKeyValues.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.

public MutableMap<K, V>
withKeyValue(K key, V value)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.withKeyValue.

This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements.

public default MutableMap<K, V>
withMap(Map<? extends K, ? extends V> map)

Overrides default org.eclipse.collections.api.map.MutableMapIterable.withMap.

Similar to putAll(Map), but returns this instead of void

public default MutableMap<K, V>
public MutableMap<K, V>
withoutAllKeys(Iterable<? extends K> keys)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.withoutAllKeys.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.

public MutableMap<K, V>
withoutKey(K key)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.withoutKey.

This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements.

public <S> MutableBag<Pair<V, S>>
zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.map.MutableMapIterable.zip, org.eclipse.collections.api.map.UnsortedMapIterable.zip.

Deprecated in 6.0. Use OrderedIterable#zip(Iterable) instead.

Returns a RichIterable formed from this RichIterable and another RichIterable by combining corresponding elements in pairs.

public MutableSet<Pair<V, Integer>>
Inherited from org.eclipse.collections.api.map.MutableMapIterable:
addcountBycountByEachcountByWithforEachgetIfAbsentPutgetIfAbsentPutgetIfAbsentPutWithgetIfAbsentPutWithKeygetOrDefaultputAllMapIterableputPairremoveAllKeysremoveIfremoveKeysumByDoublesumByFloatsumByIntsumByLongtoImmutableupdateValueupdateValueWith
Inherited from org.eclipse.collections.api.map.UnsortedMapIterable:
toImmutable