Top Constructors Methods
org.eclipse.collections.impl.map.mutable

public abstract Class AbstractMutableMapIterable<K, V>

extends AbstractMapIterable<K, V>
implements MutableMapIterable<K, V>
Class Inheritance
All Implemented Interfaces
org.eclipse.collections.api.map.MutableMapIterable, java.util.Map, org.eclipse.collections.api.map.MapIterable, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.InternalIterable, java.lang.Iterable
Known Direct Subclasses
org.eclipse.collections.impl.map.sorted.mutable.AbstractMutableSortedMap, org.eclipse.collections.impl.map.mutable.AbstractMutableMap
Imports
java.util.Iterator, .Optional, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.bag.MutableBag, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, org.eclipse.collections.api.block.function.primitive.DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, org.eclipse.collections.api.block.predicate.Predicate2, org.eclipse.collections.api.factory.Bags, .Maps, org.eclipse.collections.api.factory.primitive.ObjectDoubleMaps, .ObjectLongMaps, org.eclipse.collections.api.map.MutableMap, .MutableMapIterable, org.eclipse.collections.api.map.primitive.MutableObjectDoubleMap, .MutableObjectLongMap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.block.factory.PrimitiveFunctions, org.eclipse.collections.impl.map.AbstractMapIterable, org.eclipse.collections.impl.tuple.AbstractImmutableEntry, org.eclipse.collections.impl.utility.LazyIterate, .MapIterate

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public <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 <K2, V2> MutableMap<K2, V2>
collect(Function2<? super K, ? super V, Pair<K2, V2>> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.collect, org.eclipse.collections.api.map.MapIterable.collect.

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

public <V1> MutableBag<V1>
countBy(Function<? super V, ? extends V1> function)

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

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

public <V1> MutableBag<V1>
countByEach(Function<? super V, ? extends Iterable<V1>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

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

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

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

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

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.

public Pair<K, V>
detect(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.map.MapIterable.detect.

Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments.

public Optional<Pair<K, V>>
detectOptional(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.map.MapIterable.detectOptional.

Return the first key and value of the map as an Optional for which the predicate evaluates to true when they are given as arguments.

public MutableMap<V, K>
flipUniqueValues()

Implements org.eclipse.collections.api.map.MutableMapIterable.flipUniqueValues, org.eclipse.collections.api.map.MapIterable.flipUniqueValues.

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

public V
getIfAbsentPut(K key, Function0<? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut, org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Get and return the value in the Map at the specified key.

public V
getIfAbsentPut(K key, V value)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Get and return the value in the Map at the specified key.

public <P> V
getIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWith.

Get and return the value in the Map at the specified key.

public V
getIfAbsentPutWithKey(K key, Function<? super K, ? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWithKey.

Get and return the value in the Map at the specified key.

public <VV> MutableMapIterable<VV, V>
groupByUniqueKey(Function<? super V, ? extends VV> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.groupByUniqueKey, org.eclipse.collections.api.RichIterable.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 Iterator<V>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public RichIterable<K>
keysView()

Implements org.eclipse.collections.api.map.MapIterable.keysView.

Returns an unmodifiable lazy iterable wrapped around the keySet for the map.

public RichIterable<Pair<K, V>>
keyValuesView()

Implements org.eclipse.collections.api.map.MapIterable.keyValuesView.

Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.

public <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 <V1> MutableObjectDoubleMap<V1>
sumByDouble(Function<? super V, ? extends V1> groupBy, DoubleFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByDouble, org.eclipse.collections.api.RichIterable.sumByDouble.

Groups and sums the values using the two specified functions.

public <V1> MutableObjectDoubleMap<V1>
sumByFloat(Function<? super V, ? extends V1> groupBy, FloatFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByFloat, org.eclipse.collections.api.RichIterable.sumByFloat.

Groups and sums the values using the two specified functions.

public <V1> MutableObjectLongMap<V1>
sumByInt(Function<? super V, ? extends V1> groupBy, IntFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByInt, org.eclipse.collections.api.RichIterable.sumByInt.

Groups and sums the values using the two specified functions.

public <V1> MutableObjectLongMap<V1>
sumByLong(Function<? super V, ? extends V1> groupBy, LongFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

public V
updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Looks up the value associated with key, applies the function to it, and replaces the value.

public <P> V
updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Same as updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.

public RichIterable<V>
valuesView()

Implements org.eclipse.collections.api.map.MapIterable.valuesView.

Returns an unmodifiable lazy iterable wrapped around the values for the map.

Inherited from org.eclipse.collections.impl.map.AbstractMapIterable:
allSatisfyallSatisfyWithanySatisfyanySatisfyWithasLazychunkcontainsdetectdetectIfNonedetectOptionaldetectWithdetectWithIfNonedetectWithOptionaleachforEachKeyforEachValueforEachWithforEachWithIndexgetFirstgetIfAbsentgetIfAbsentValuegetIfAbsentWithgetLastgetOnlygetOrDefaultifPresentApplyisAbsentkeyAndValueEqualskeyAndValueHashCodenoneSatisfynoneSatisfyWithtoArraytoArray

Constructor Detail

AbstractMutableMapIterableback to summary
public AbstractMutableMapIterable()

Method Detail

aggregateByback to summary
public <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.

Doc from 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. Aggregate results are allowed to be immutable as they will be replaced in place in the map. A second function specifies the initial "zero" aggregate value to work with.

MapIterable<String, Interval> map = Maps.mutable.with("oneToFive", Interval.fromTo(1, 5), "sixToNine", Interval.fromTo(6, 9));

MapIterable<String, Long> result = map.aggregateBy(
        eachKey -> {
            return eachKey.equals("oneToFive")  ? "lessThanSix" : "greaterOrEqualsToSix";
        },
        each -> each.sumOfInt(Integer::intValue),
        () -> 0L,
        (argument1, argument2) -> argument1 + argument2);

MapIterable<String, Long> expected =
        Maps.mutable.with("lessThanSix", Interval.fromTo(1, 5).sumOfInt(Integer::intValue),
                "greaterOrEqualsToSix", Interval.fromTo(6, 9).sumOfInt(Integer::intValue));
Assert.assertEquals(expected, result);
Annotations
@Override
collectback to summary
public <K2, V2> MutableMap<K2, V2> collect(Function2<? super K, ? super V, Pair<K2, V2>> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.collect, org.eclipse.collections.api.map.MapIterable.collect.

Doc from org.eclipse.collections.api.map.MapIterable.collect.

For each key and value of the map the function is evaluated. The results of these evaluations are returned in a new map. The map returned will use the values projected from the function rather than the original values.

MapIterable<String, String> collected =
    peopleByCity.collect((City city, Person person) -> Pair.of(city.getCountry(), person.getAddress().getCity()));
Annotations
@Override
countByback to summary
public <V1> MutableBag<V1> countBy(Function<? super V, ? extends V1> function)

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

Doc from org.eclipse.collections.api.RichIterable.countBy.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

Annotations
@Override
Since
9.0
countByEachback to summary
public <V1> MutableBag<V1> countByEach(Function<? super V, ? extends Iterable<V1>> function)

Overrides org.eclipse.collections.impl.AbstractRichIterable.countByEach.

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

Doc from org.eclipse.collections.api.RichIterable.countByEach.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.

Annotations
@Override
Since
10.0.0
countByWithback to summary
public <V1, P> MutableBag<V1> countByWith(Function2<? super V, ? super P, ? extends V1> function, P parameter)

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

Doc from org.eclipse.collections.api.RichIterable.countByWith.

This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.

Annotations
@Override
Since
9.0
detectback to summary
public Pair<K, V> detect(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.map.MapIterable.detect.

Doc from org.eclipse.collections.api.map.MapIterable.detect.

Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments. The predicate will only be evaluated until such pair is found or until all the keys and values of the map have been used as arguments. That is, there may be keys and values of the map that are never used as arguments to the predicate. The result is null if predicate does not evaluate to true for any key/value combination.

Pair<City, Person> detected =
    peopleByCity.detect((City city, Person person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
Annotations
@Override
detectOptionalback to summary
public Optional<Pair<K, V>> detectOptional(Predicate2<? super K, ? super V> predicate)

Implements org.eclipse.collections.api.map.MapIterable.detectOptional.

Doc from org.eclipse.collections.api.map.MapIterable.detectOptional.

Return the first key and value of the map as an Optional for which the predicate evaluates to true when they are given as arguments. The predicate will only be evaluated until such pair is found or until all the keys and values of the map have been used as arguments. That is, there may be keys and values of the map that are never used as arguments to the predicate.

Optional<Pair<City, Person>> detected =
    peopleByCity.detectOptional((city, person)
         -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
Annotations
@Override
flipUniqueValuesback to summary
public MutableMap<V, K> flipUniqueValues()

Implements org.eclipse.collections.api.map.MutableMapIterable.flipUniqueValues, org.eclipse.collections.api.map.MapIterable.flipUniqueValues.

Doc from org.eclipse.collections.api.map.MapIterable.flipUniqueValues.

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

    MapIterable<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
    MapIterable<String, Integer> result = map.flipUniqueValues();
    Assert.assertTrue(result.equals(UnifiedMap.newWithKeysValues("1", 1, "2", 2, "3", 3)));
Annotations
@Override
getIfAbsentPutback to summary
public V getIfAbsentPut(K key, Function0<? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut, org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Doc from org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the result of evaluating the specified Function0, and put that value in the map at the specified key.

Annotations
@Override
getIfAbsentPutback to summary
public V getIfAbsentPut(K key, V value)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Doc from org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPut.

Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map at the key, return the specified value, and put that value in the map at the specified key.

Annotations
@Override
getIfAbsentPutWithback to summary
public <P> V getIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWith.

Doc from org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWith.

Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key return the result of evaluating the specified Function using the specified parameter, and put that value in the map at the specified key.

Annotations
@Override
getIfAbsentPutWithKeyback to summary
public V getIfAbsentPutWithKey(K key, Function<? super K, ? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWithKey.

Doc from org.eclipse.collections.api.map.MutableMapIterable.getIfAbsentPutWithKey.

Get and return the value in the Map at the specified key. Alternatively, if there is no value in the map for that key return the result of evaluating the specified Function using the specified key, and put that value in the map at the specified key.

Annotations
@Override
groupByUniqueKeyback to summary
public <VV> MutableMapIterable<VV, V> groupByUniqueKey(Function<? super V, ? extends VV> function)

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

Doc from org.eclipse.collections.api.RichIterable.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. The generated keys must each be unique, or else an exception is thrown.

Annotations
@Override
iteratorback to summary
public Iterator<V> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Annotations
@Override
keysViewback to summary
public RichIterable<K> keysView()

Implements org.eclipse.collections.api.map.MapIterable.keysView.

Doc from org.eclipse.collections.api.map.MapIterable.keysView.

Returns an unmodifiable lazy iterable wrapped around the keySet for the map.

Annotations
@Override
keyValuesViewback to summary
public RichIterable<Pair<K, V>> keyValuesView()

Implements org.eclipse.collections.api.map.MapIterable.keyValuesView.

Doc from org.eclipse.collections.api.map.MapIterable.keyValuesView.

Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.

Annotations
@Override
reduceByback to summary
public <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.

Doc from org.eclipse.collections.api.RichIterable.reduceBy.

Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function. Aggregate results are allowed to be immutable as they will be replaced in place in the map.

Annotations
@Override
sumByDoubleback to summary
public <V1> MutableObjectDoubleMap<V1> sumByDouble(Function<? super V, ? extends V1> groupBy, DoubleFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByDouble, org.eclipse.collections.api.RichIterable.sumByDouble.

Doc from org.eclipse.collections.api.RichIterable.sumByDouble.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByFloatback to summary
public <V1> MutableObjectDoubleMap<V1> sumByFloat(Function<? super V, ? extends V1> groupBy, FloatFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByFloat, org.eclipse.collections.api.RichIterable.sumByFloat.

Doc from org.eclipse.collections.api.RichIterable.sumByFloat.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByIntback to summary
public <V1> MutableObjectLongMap<V1> sumByInt(Function<? super V, ? extends V1> groupBy, IntFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByInt, org.eclipse.collections.api.RichIterable.sumByInt.

Doc from org.eclipse.collections.api.RichIterable.sumByInt.

Groups and sums the values using the two specified functions.

Annotations
@Override
sumByLongback to summary
public <V1> MutableObjectLongMap<V1> sumByLong(Function<? super V, ? extends V1> groupBy, LongFunction<? super V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.sumByLong, org.eclipse.collections.api.RichIterable.sumByLong.

Doc from org.eclipse.collections.api.RichIterable.sumByLong.

Groups and sums the values using the two specified functions.

Annotations
@Override
updateValueback to summary
public V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function)

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Doc from org.eclipse.collections.api.map.MutableMapIterable.updateValue.

Looks up the value associated with key, applies the function to it, and replaces the value. If there is no value associated with key, starts it off with a value supplied by factory.

Annotations
@Override
updateValueWithback to summary
public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)

Implements org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Doc from org.eclipse.collections.api.map.MutableMapIterable.updateValueWith.

Same as updateValue(Object, Function0, Function) with a Function2 and specified parameter which is passed to the function.

Annotations
@Override
valuesViewback to summary
public RichIterable<V> valuesView()

Implements org.eclipse.collections.api.map.MapIterable.valuesView.

Doc from org.eclipse.collections.api.map.MapIterable.valuesView.

Returns an unmodifiable lazy iterable wrapped around the values for the map.

Annotations
@Override