| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public <K1, V1, V2> MutableMap | 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. 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 | collect(Function2<? super K, ? super V, Pair<K2, V2>> function)
Implements org. For each key and value of the map the function is evaluated. |
| public <V1> MutableBag | countBy(Function<? super V, ? extends V1> function)
Overrides default org. 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 | countByEach(Function<? super V, ? extends Iterable<V1>> function)
Overrides org. Overrides default org. 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 | countByWith(Function2<? super V, ? super P, ? extends V1> function, P parameter)
Overrides default org. 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 | detect(Predicate2<? super K, ? super V> predicate)
Implements org. Return the first key and value of the map for which the predicate evaluates to true when they are given as arguments. |
| public Optional | detectOptional(Predicate2<? super K, ? super V> predicate)
Implements org. 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 | flipUniqueValues()
Implements org. 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. Get and return the value in the Map at the specified key. |
| public V | getIfAbsentPut(K key, V value)
Implements org. 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. 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. Get and return the value in the Map at the specified key. |
| public <VV> MutableMapIterable | groupByUniqueKey(Function<? super V, ? extends VV> function)
Implements org. 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 | |
| public RichIterable | keysView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map. |
| public RichIterable | keyValuesView()
Implements org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map. |
| public <KK> MutableMap | reduceBy(Function<? super V, ? extends KK> groupBy, Function2<? super V, ? super V, ? extends V> reduceFunction)
Overrides default org. Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function. |
| public <V1> MutableObjectDoubleMap | sumByDouble(Function<? super V, ? extends V1> groupBy, DoubleFunction<? super V> function)
Implements org. Groups and sums the values using the two specified functions. |
| public <V1> MutableObjectDoubleMap | sumByFloat(Function<? super V, ? extends V1> groupBy, FloatFunction<? super V> function)
Implements org. Groups and sums the values using the two specified functions. |
| public <V1> MutableObjectLongMap | sumByInt(Function<? super V, ? extends V1> groupBy, IntFunction<? super V> function)
Implements org. Groups and sums the values using the two specified functions. |
| public <V1> MutableObjectLongMap | sumByLong(Function<? super V, ? extends V1> groupBy, LongFunction<? super V> function)
Implements org. 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. Looks up the value associated with |
| public <P> V | updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter)
Implements org. Same as |
| public RichIterable | valuesView()
Implements org. Returns an unmodifiable lazy iterable wrapped around the values for the map. |
| AbstractMutableMapIterable | back to summary |
|---|---|
| public AbstractMutableMapIterable() | |
| aggregateBy | back to summary |
|---|---|
| public <K1, V1, V2> MutableMap Overrides default org. Doc from org. 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);
| |
| collect | back to summary |
|---|---|
| public <K2, V2> MutableMap Implements org. Doc from org. 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()));
| |
| countBy | back to summary |
|---|---|
| public <V1> MutableBag Overrides default org. Doc from org. This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
| |
| countByEach | back to summary |
|---|---|
| public <V1> MutableBag Overrides org. Overrides default org. Doc from org. This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
| |
| countByWith | back to summary |
|---|---|
| public <V1, P> MutableBag Overrides default org. Doc from org. 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.
| |
| detect | back to summary |
|---|---|
| public Pair Implements org. Doc from org. 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"));
| |
| detectOptional | back to summary |
|---|---|
| public Optional Implements org. Doc from org. 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"));
| |
| flipUniqueValues | back to summary |
|---|---|
| public MutableMap Implements org. Doc from org. 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)));
| |
| getIfAbsentPut | back to summary |
|---|---|
| public V getIfAbsentPut(K key, Function0<? extends V> function) Implements org. Doc from org. 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.
| |
| getIfAbsentPut | back to summary |
|---|---|
| public V getIfAbsentPut(K key, V value) Implements org. Doc from org. 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.
| |
| getIfAbsentPutWith | back to summary |
|---|---|
| public <P> V getIfAbsentPutWith(K key, Function<? super P, ? extends V> function, P parameter) Implements org. Doc from org. 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.
| |
| getIfAbsentPutWithKey | back to summary |
|---|---|
| public V getIfAbsentPutWithKey(K key, Function<? super K, ? extends V> function) Implements org. Doc from org. 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.
| |
| groupByUniqueKey | back to summary |
|---|---|
| public <VV> MutableMapIterable Implements org. Doc from org. 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.
| |
| iterator | back to summary |
|---|---|
| public Iterator Implements java. Doc from java. Returns an iterator over elements of type
| |
| keysView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the keySet for the map.
| |
| keyValuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.
| |
| reduceBy | back to summary |
|---|---|
| public <KK> MutableMap Overrides default org. Doc from org. 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.
| |
| sumByDouble | back to summary |
|---|---|
| public <V1> MutableObjectDoubleMap Implements org. Doc from org. Groups and sums the values using the two specified functions.
| |
| sumByFloat | back to summary |
|---|---|
| public <V1> MutableObjectDoubleMap Implements org. Doc from org. Groups and sums the values using the two specified functions.
| |
| sumByInt | back to summary |
|---|---|
| public <V1> MutableObjectLongMap Implements org. Doc from org. Groups and sums the values using the two specified functions.
| |
| sumByLong | back to summary |
|---|---|
| public <V1> MutableObjectLongMap Implements org. Doc from org. Groups and sums the values using the two specified functions.
| |
| updateValue | back to summary |
|---|---|
| public V updateValue(K key, Function0<? extends V> factory, Function<? super V, ? extends V> function) Implements org. Doc from org. Looks up the value associated with
| |
| updateValueWith | back to summary |
|---|---|
| public <P> V updateValueWith(K key, Function0<? extends V> factory, Function2<? super V, ? super P, ? extends V> function, P parameter) Implements org. Doc from org. Same as
| |
| valuesView | back to summary |
|---|---|
| public RichIterable Implements org. Doc from org. Returns an unmodifiable lazy iterable wrapped around the values for the map.
| |