public abstract class AbstractMutableMapIterable<K,V> extends AbstractMapIterable<K,V> implements MutableMapIterable<K,V>
| Constructor and Description |
|---|
AbstractMutableMapIterable() |
| Modifier and Type | Method and Description |
|---|---|
<K2,V2> MutableMap<K2,V2> |
aggregateBy(Function<? super V,? extends K2> groupBy,
Function0<? extends V2> zeroValueFactory,
Function2<? super V2,? super V,? extends V2> nonMutatingAggregator)
Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.
|
<K2,V2> MutableMap<K2,V2> |
aggregateInPlaceBy(Function<? super V,? extends K2> groupBy,
Function0<? extends V2> zeroValueFactory,
Procedure2<? super V2,? super V> mutatingAggregator)
Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.
|
<K2,V2> MutableMap<K2,V2> |
collect(Function2<? super K,? super V,Pair<K2,V2>> function)
For each key and value of the map the function is evaluated.
|
Pair<K,V> |
detect(Predicate2<? super K,? super V> predicate)
Return the first key and value of the map for which the predicate evaluates to true when they are given
as arguments.
|
Optional<Pair<K,V>> |
detectOptional(Predicate2<? super K,? super V> predicate)
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.
|
MutableMap<V,K> |
flipUniqueValues()
Return the MapIterable that is obtained by flipping the direction of this map and making the associations
from value to key.
|
V |
getIfAbsentPut(K key,
Function0<? extends V> function)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentPut(K key,
V value)
Get and return the value in the Map at the specified key.
|
<P> V |
getIfAbsentPutWith(K key,
Function<? super P,? extends V> function,
P parameter)
Get and return the value in the Map at the specified key.
|
V |
getIfAbsentPutWithKey(K key,
Function<? super K,? extends V> function)
Get and return the value in the Map at the specified key.
|
<VV> MutableMapIterable<VV,V> |
groupByUniqueKey(Function<? super V,? extends VV> function)
For each element of the iterable, the function is evaluated and he results of these evaluations are collected
into a new map, where the transformed value is the key.
|
Iterator<V> |
iterator() |
RichIterable<K> |
keysView()
Returns an unmodifiable lazy iterable wrapped around the keySet for the map.
|
RichIterable<Pair<K,V>> |
keyValuesView()
Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
|
<V1> MutableObjectDoubleMap<V1> |
sumByDouble(Function<? super V,? extends V1> groupBy,
DoubleFunction<? super V> function)
Groups and sums the values using the two specified functions.
|
<V1> MutableObjectDoubleMap<V1> |
sumByFloat(Function<? super V,? extends V1> groupBy,
FloatFunction<? super V> function)
Groups and sums the values using the two specified functions.
|
<V1> MutableObjectLongMap<V1> |
sumByInt(Function<? super V,? extends V1> groupBy,
IntFunction<? super V> function)
Groups and sums the values using the two specified functions.
|
<V1> MutableObjectLongMap<V1> |
sumByLong(Function<? super V,? extends V1> groupBy,
LongFunction<? super V> function)
Groups and sums the values using the two specified functions.
|
V |
updateValue(K key,
Function0<? extends V> factory,
Function<? super V,? extends V> function)
Looks up the value associated with
key, applies the function to it, and replaces the value. |
<P> V |
updateValueWith(K key,
Function0<? extends V> factory,
Function2<? super V,? super P,? extends V> function,
P parameter)
Same as
MutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function. |
RichIterable<V> |
valuesView()
Returns an unmodifiable lazy iterable wrapped around the values for the map.
|
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArrayappendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexequals, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, asSynchronized, asUnmodifiable, collectValues, flip, groupBy, groupByEach, newEmpty, partition, reject, reject, rejectWith, removeKey, select, select, selectInstancesOf, selectWith, tap, toImmutable, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexcontainsKey, containsValue, equals, forEachKey, forEachKeyValue, forEachValue, get, getIfAbsent, getIfAbsentValue, getIfAbsentWith, hashCode, ifPresentApply, toStringallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collect, collectBoolean, collectBoolean, collectByte, collectByte, collectChar, collectChar, collectDouble, collectDouble, collectFloat, collectFloat, collectIf, collectIf, collectInt, collectInt, collectLong, collectLong, collectShort, collectShort, collectWith, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollect, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, partitionWith, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEach, forEachWith, forEachWithIndexforEach, spliteratorclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic V getIfAbsentPut(K key, Function0<? extends V> function)
MutableMapIterablegetIfAbsentPut in interface MutableMapIterable<K,V>public V getIfAbsentPut(K key, V value)
MutableMapIterablegetIfAbsentPut in interface MutableMapIterable<K,V>public V getIfAbsentPutWithKey(K key, Function<? super K,? extends V> function)
MutableMapIterablegetIfAbsentPutWithKey in interface MutableMapIterable<K,V>public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
MutableMapIterablegetIfAbsentPutWith in interface MutableMapIterable<K,V>public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
MutableMapIterablekey, 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.updateValue in interface MutableMapIterable<K,V>public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V,? super P,? extends V> function, P parameter)
MutableMapIterableMutableMapIterable.updateValue(Object, Function0, Function) with a Function2 and specified parameter which is
passed to the function.updateValueWith in interface MutableMapIterable<K,V>public <VV> MutableMapIterable<VV,V> groupByUniqueKey(Function<? super V,? extends VV> function)
RichIterablegroupByUniqueKey in interface MutableMapIterable<K,V>groupByUniqueKey in interface RichIterable<V>RichIterable.groupBy(Function)public <K2,V2> MutableMap<K2,V2> aggregateInPlaceBy(Function<? super V,? extends K2> groupBy, Function0<? extends V2> zeroValueFactory, Procedure2<? super V2,? super V> mutatingAggregator)
RichIterableaggregateInPlaceBy in interface MutableMapIterable<K,V>aggregateInPlaceBy in interface RichIterable<V>public <K2,V2> MutableMap<K2,V2> aggregateBy(Function<? super V,? extends K2> groupBy, Function0<? extends V2> zeroValueFactory, Function2<? super V2,? super V,? extends V2> nonMutatingAggregator)
RichIterableaggregateBy in interface MutableMapIterable<K,V>aggregateBy in interface RichIterable<V>public RichIterable<K> keysView()
MapIterablekeysView in interface MapIterable<K,V>public RichIterable<V> valuesView()
MapIterablevaluesView in interface MapIterable<K,V>public RichIterable<Pair<K,V>> keyValuesView()
MapIterablekeyValuesView in interface MapIterable<K,V>public <K2,V2> MutableMap<K2,V2> collect(Function2<? super K,? super V,Pair<K2,V2>> function)
MapIterable
MapIterable<String, String> collected =
peopleByCity.collect((City city, Person person) -> Pair.of(city.getCountry(), person.getAddress().getCity()));
collect in interface MapIterable<K,V>collect in interface MutableMapIterable<K,V>public MutableMap<V,K> flipUniqueValues()
MapIterable
MapIterable map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3");
MapIterable result = map.flipUniqueValues();
Assert.assertTrue(result.equals(UnifiedMap.newWithKeysValues("1", 1, "2", 2, "3", 3)));
flipUniqueValues in interface MapIterable<K,V>flipUniqueValues in interface MutableMapIterable<K,V>public Pair<K,V> detect(Predicate2<? super K,? super V> predicate)
MapIterable
Pair<City, Person> detected =
peopleByCity.detect((City city, Person person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
detect in interface MapIterable<K,V>public Optional<Pair<K,V>> detectOptional(Predicate2<? super K,? super V> predicate)
MapIterable
Optional<Pair<City, Person>> detected =
peopleByCity.detectOptional((city, person)
-> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
detectOptional in interface MapIterable<K,V>public <V1> MutableObjectLongMap<V1> sumByInt(Function<? super V,? extends V1> groupBy, IntFunction<? super V> function)
RichIterablesumByInt in interface MutableMapIterable<K,V>sumByInt in interface RichIterable<V>public <V1> MutableObjectDoubleMap<V1> sumByFloat(Function<? super V,? extends V1> groupBy, FloatFunction<? super V> function)
RichIterablesumByFloat in interface MutableMapIterable<K,V>sumByFloat in interface RichIterable<V>public <V1> MutableObjectLongMap<V1> sumByLong(Function<? super V,? extends V1> groupBy, LongFunction<? super V> function)
RichIterablesumByLong in interface MutableMapIterable<K,V>sumByLong in interface RichIterable<V>public <V1> MutableObjectDoubleMap<V1> sumByDouble(Function<? super V,? extends V1> groupBy, DoubleFunction<? super V> function)
RichIterablesumByDouble in interface MutableMapIterable<K,V>sumByDouble in interface RichIterable<V>Copyright © 2004–2017. All rights reserved.