Iterable<K>
, Map<K,V>
, InternalIterable<K>
, MapIterable<K,V>
, MutableMapIterable<K,V>
, RichIterable<K>
AbstractMutableMap
, AbstractMutableSortedMap
public abstract class AbstractMutableMapIterable<K,V> extends AbstractMapIterable<K,V> implements MutableMapIterable<K,V>
Constructor | Description |
---|---|
AbstractMutableMapIterable() |
Modifier and Type | Method | 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.
|
<V1> MutableBag<V1> |
countBy(Function<? super V,? extends V1> function) |
This method will count the number of occurrences of each value calculated by applying the
function to each element of the collection.
|
<V1> MutableBag<V1> |
countByEach(Function<? super V,? extends Iterable<V1>> function) |
This method will count the number of occurrences of each value calculated by applying the
function to each element of the collection.
|
<V1,P> MutableBag<V1> |
countByWith(Function2<? super V,? super P,? extends V1> function,
P parameter) |
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.
|
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, toArray
appendString, 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, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
forEach, forEachWith, forEachWithIndex
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entry, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, of, of, of, of, of, of, of, of, of, of, of, ofEntries, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
containsKey, containsValue, equals, forEachKey, forEachKeyValue, forEachValue, get, getIfAbsent, getIfAbsentValue, getIfAbsentWith, hashCode, ifPresentApply, parallelStream, spliterator, stream, toString
add, asSynchronized, asUnmodifiable, collectValues, flip, groupBy, groupByEach, newEmpty, partition, putPair, reject, reject, rejectWith, removeAllKeys, removeIf, removeKey, select, select, selectInstancesOf, selectWith, tap, toImmutable, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndex
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
allSatisfy, 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, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollect, flatCollectWith, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, isEmpty, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, partitionWith, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, size, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
public V getIfAbsentPut(K key, Function0<? extends V> function)
MutableMapIterable
getIfAbsentPut
in interface MutableMapIterable<K,V>
public V getIfAbsentPut(K key, V value)
MutableMapIterable
getIfAbsentPut
in interface MutableMapIterable<K,V>
public V getIfAbsentPutWithKey(K key, Function<? super K,? extends V> function)
MutableMapIterable
getIfAbsentPutWithKey
in interface MutableMapIterable<K,V>
public <P> V getIfAbsentPutWith(K key, Function<? super P,? extends V> function, P parameter)
MutableMapIterable
getIfAbsentPutWith
in interface MutableMapIterable<K,V>
public V updateValue(K key, Function0<? extends V> factory, Function<? super V,? extends V> function)
MutableMapIterable
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
.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)
MutableMapIterable
MutableMapIterable.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)
RichIterable
groupByUniqueKey
in interface MutableMapIterable<K,V>
groupByUniqueKey
in interface RichIterable<K>
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)
RichIterable
aggregateInPlaceBy
in interface MutableMapIterable<K,V>
aggregateInPlaceBy
in interface RichIterable<K>
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)
RichIterable
aggregateBy
in interface MutableMapIterable<K,V>
aggregateBy
in interface RichIterable<K>
public RichIterable<K> keysView()
MapIterable
keysView
in interface MapIterable<K,V>
public RichIterable<V> valuesView()
MapIterable
valuesView
in interface MapIterable<K,V>
public RichIterable<Pair<K,V>> keyValuesView()
MapIterable
keyValuesView
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<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)));
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)
RichIterable
sumByInt
in interface MutableMapIterable<K,V>
sumByInt
in interface RichIterable<K>
public <V1> MutableObjectDoubleMap<V1> sumByFloat(Function<? super V,? extends V1> groupBy, FloatFunction<? super V> function)
RichIterable
sumByFloat
in interface MutableMapIterable<K,V>
sumByFloat
in interface RichIterable<K>
public <V1> MutableObjectLongMap<V1> sumByLong(Function<? super V,? extends V1> groupBy, LongFunction<? super V> function)
RichIterable
sumByLong
in interface MutableMapIterable<K,V>
sumByLong
in interface RichIterable<K>
public <V1> MutableObjectDoubleMap<V1> sumByDouble(Function<? super V,? extends V1> groupBy, DoubleFunction<? super V> function)
RichIterable
sumByDouble
in interface MutableMapIterable<K,V>
sumByDouble
in interface RichIterable<K>
public <V1> MutableBag<V1> countBy(Function<? super V,? extends V1> function)
RichIterable
countBy
in interface MutableMapIterable<K,V>
countBy
in interface RichIterable<K>
public <V1,P> MutableBag<V1> countByWith(Function2<? super V,? super P,? extends V1> function, P parameter)
RichIterable
countByWith
in interface MutableMapIterable<K,V>
countByWith
in interface RichIterable<K>
public <V1> MutableBag<V1> countByEach(Function<? super V,? extends Iterable<V1>> function)
RichIterable
countByEach
in interface MutableMapIterable<K,V>
countByEach
in interface RichIterable<K>
countByEach
in class AbstractRichIterable<V>
Copyright © 2004–2019. All rights reserved.