public abstract class AbstractMutableMapIterable<K,V> extends AbstractMapIterable<K,V> implements MutableMapIterable<K,V>
Constructor and Description |
---|
AbstractMutableMapIterable() |
Modifier and Type | Method and Description |
---|---|
V |
add(Pair<K,V> keyValuePair)
This method allows mutable map the ability to add an element in the form of Pair
|
<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.
|
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.
|
<V1> MutableMap<V1,V> |
groupByUniqueKey(Function<? super V,? extends V1> 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
|
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, detectWith, detectWithIfNone, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArray
appendString, 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, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, notEmpty, reject, rejectWith, select, selectWith, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndex
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
asSynchronized, asUnmodifiable, collectValues, flip, groupBy, groupByEach, newEmpty, partition, reject, reject, rejectWith, removeKey, select, select, selectInstancesOf, selectWith, tap, toImmutable, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndex
containsKey, containsValue, equals, forEachKey, forEachKeyValue, forEachValue, get, getIfAbsent, getIfAbsentValue, getIfAbsentWith, hashCode, ifPresentApply, toString
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, countWith, detect, detectIfNone, detectWith, detectWithIfNone, each, flatCollect, flatCollect, getFirst, getLast, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, isEmpty, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, partitionWith, reject, rejectWith, select, selectWith, size, sumByDouble, sumByFloat, sumByInt, sumByLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
forEach, forEachWith, forEachWithIndex
forEach, spliterator
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
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 add(Pair<K,V> keyValuePair)
MutableMapIterable
add
in interface MutableMapIterable<K,V>
Map.put(Object, Object)
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 <V1> MutableMap<V1,V> groupByUniqueKey(Function<? super V,? extends V1> function)
RichIterable
groupByUniqueKey
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)
RichIterable
aggregateInPlaceBy
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)
RichIterable
aggregateBy
in interface MutableMapIterable<K,V>
aggregateBy
in interface RichIterable<V>
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
e.g. peopleByCity.collect(new Function2<City, Person, String>() { public String value(City city, Person person) { return 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
MapIterablemap = 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
e.g. peopleByCity.detect(new Predicate2<City, Person>() { public boolean accept(City city, Person person) { return city.getName().equals("Anytown") && person.getLastName().equals("Smith"); } });
detect
in interface MapIterable<K,V>
Copyright © 2004–2016. All rights reserved.