BiMap whose contents can be altered after initialization.
| Modifier and Type | Method and Description |
|---|---|
| public default <KK, VV> MutableMap | aggregateBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super V, ? extends VV> nonMutatingAggregator)
Overrides default org. Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function. |
| public default <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 MutableBiMap | asSynchronized()
Redeclares org. Returns a synchronized wrapper backed by this map. |
| public MutableBiMap | asUnmodifiable()
Redeclares org. Returns an unmodifiable view of this map. |
| public MutableBiMap | |
| public <K2, V2> MutableBiMap | collect(Function2<? super K, ? super V, Pair<K2, V2>> function)
Redeclares org. For each key and value of the map the function is evaluated. |
| public <R> MutableBiMap | collectKeysUnique(Function2<? super K, ? super V, ? extends R> function)
Redeclares org. For each key and value of the map the function is evaluated. |
| public <R> MutableBiMap | collectValues(Function2<? super K, ? super V, ? extends R> function)
Redeclares org. For each key and value of the map the function is evaluated. |
| public MutableSetMultimap | flip()
Redeclares org. Given a map from Domain |
| public MutableBiMap | flipUniqueValues()
Redeclares org. Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key. |
| public V | forcePut(K key, V value)
Similar to |
| public <V1> MutableSetMultimap | groupBy(Function<? super V, ? extends V1> function)
Redeclares org. For each element of the iterable, the function is evaluated and the results of these evaluations are collected into a new multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. |
| public <V1> MutableSetMultimap | groupByEach(Function<? super V, ? extends Iterable<V1>> function)
Redeclares org. Similar to |
| public default <VV> MutableBiMap | 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 MutableBiMap | inverse()
Redeclares org. Returns an inversed view of this BiMap, where the associations are in the direction of this bimap's values to keys. |
| public MutableBiMap | newEmpty()
Redeclares org. Creates a new instance of the same type, using the default capacity and growth parameters. |
| public PartitionMutableSet | partition(Predicate<? super V> predicate)
Redeclares org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. |
| public <P> PartitionMutableSet | partitionWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. |
| public V | put(K key, V value)
Redeclares java. Similar to |
| public default <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 MutableBiMap | reject(Predicate2<? super K, ? super V> predicate)
Redeclares org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map. |
| public MutableSet | reject(Predicate<? super V> predicate)
Redeclares org. Returns all elements of the source collection that return false when evaluating of the predicate. |
| public <P> MutableSet | rejectWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Similar to |
| public MutableBiMap | select(Predicate2<? super K, ? super V> predicate)
Redeclares org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map. |
| public MutableSet | select(Predicate<? super V> predicate)
Redeclares org. Returns all elements of the source collection that return true when evaluating the predicate. |
| public <S> MutableSet | selectInstancesOf(Class<S> clazz)
Redeclares org. Returns all elements of the source collection that are instances of the Class |
| public <P> MutableSet | selectWith(Predicate2<? super V, ? super P> predicate, P parameter)
Redeclares org. Similar to |
| public MutableBiMap | tap(Procedure<? super V> procedure)
Redeclares org. Executes the Procedure for each value of the map and returns |
| public MutableBiMap | withAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs)
Redeclares org. Convenience var-args version of withAllKeyValues |
| public MutableBiMap | withAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues)
Redeclares org. This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. |
| public MutableBiMap | withKeyValue(K key, V value)
Redeclares org. This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. |
| public default MutableBiMap | withMap(Map<? extends K, ? extends V> map)
Overrides default org. Similar to |
| public default MutableBiMap | withMapIterable(MapIterable<? extends K, ? extends V> mapIterable)
Overrides default org.
|
| public MutableBiMap | withoutAllKeys(Iterable<? extends K> keys)
Redeclares org. This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. |
| public MutableBiMap | withoutKey(K key)
Redeclares org. This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. |
| public <S> MutableSet | zip(Iterable<S> that)
Redeclares org.
Deprecated
in 8.0. Use
OrderedIterable#zip(Iterable) instead.
Returns a |
| public MutableSet | zipWithIndex()
Redeclares org.
Deprecated
in 8.0. Use
OrderedIterable#zipWithIndex() instead.
Zips this |
| aggregateBy | back to summary |
|---|---|
| public default <KK, VV> 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. A second function specifies the initial "zero" aggregate value to work with (i.e. Integer.valueOf(0)).
| |
| aggregateBy | back to summary |
|---|---|
| public default <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);
| |
| asSynchronized | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Returns a synchronized wrapper backed by this map. This is the equivalent of calling
The preferred way of iterating over a synchronized map is to use the forEachKey(), forEachValue() and forEachKeyValue() methods which are properly synchronized internally. MutableMap synchedMap = map.asSynchronized(); synchedMap.forEachKey(key -> ... ); synchedMap.forEachValue(value -> ... ); synchedMap.forEachKeyValue((key, value) -> ... ); If you want to iterate imperatively over the keySet(), values(), or entrySet(), you will need to protect the iteration by wrapping the code in a synchronized block on the map.
| |
| asUnmodifiable | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Returns an unmodifiable view of this map. This is the equivalent of using
| |
| clone | back to summary |
|---|---|
| public MutableBiMap | |
| collect | back to summary |
|---|---|
| public <K2, V2> MutableBiMap Redeclares 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()));
Implementations are expected to delegate to MutableBiMap#put(Object, Object),
ImmutableBiMap#newWithKeyValue(Object, Object), or equivalent, not MutableBiMap#forcePut(Object, Object).
| |
| collectKeysUnique | back to summary |
|---|---|
| public <R> MutableBiMap Redeclares 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 keys projected from the function rather than the original keys.
| |
| collectValues | back to summary |
|---|---|
| public <R> MutableBiMap Redeclares 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<City, String> collected =
peopleByCity.collectValues((City city, Person person) -> person.getFirstName() + " " + person.getLastName());
Implementations are expected to delegate to MutableBiMap#put(Object, Object),
ImmutableBiMap#newWithKeyValue(Object, Object), or equivalent, not MutableBiMap#forcePut(Object, Object).
| |
| flip | back to summary |
|---|---|
| public MutableSetMultimap Redeclares org. Doc from org. Given a map from Domain Since the keys in the input are unique, the values in the output are unique, so the return type should be a SetMultimap. However, since SetMultimap and SortedSetMultimap don't inherit from one another, SetMultimap here does not allow SortedMapIterable to have a SortedSetMultimap return. Thus, we compromise and call this Multimap, even though all implementations will be a SetMultimap or SortedSetMultimap.
| |
| flipUniqueValues | back to summary |
|---|---|
| public MutableBiMap Redeclares 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)));
| |
| forcePut | back to summary |
|---|---|
| public V forcePut(K key, V value) Similar to | |
| groupBy | back to summary |
|---|---|
| public <V1> MutableSetMultimap Redeclares 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 multimap, where the transformed value is the key and the original values are added to the same (or similar) species of collection as the source iterable. Example using a Java 8 method reference:
Multimap<String, Person> peopleByLastName =
people.groupBy(Person::getLastName);
| |
| groupByEach | back to summary |
|---|---|
| public <V1> MutableSetMultimap Redeclares org. Doc from org. Similar to
| |
| groupByUniqueKey | back to summary |
|---|---|
| public default <VV> MutableBiMap 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.
| |
| inverse | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Returns an inversed view of this BiMap, where the associations are in the direction of this bimap's values to keys.
| |
| newEmpty | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Creates a new instance of the same type, using the default capacity and growth parameters.
| |
| partition | back to summary |
|---|---|
| public PartitionMutableSet Redeclares org. Doc from org. Filters a collection into a PartitionedIterable based on the evaluation of the predicate. Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partition(person -> person.getAddress().getState().getName().equals("New York"));
| |
| partitionWith | back to summary |
|---|---|
| public <P> PartitionMutableSet Redeclares org. Doc from org. Filters a collection into a PartitionIterable based on the evaluation of the predicate. Example using a Java 8 lambda expression:
PartitionIterable<Person> newYorkersAndNonNewYorkers =
people.partitionWith((Person person, String state) -> person.getAddress().getState().getName().equals(state), "New York");
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Redeclares java. Similar to
| |
| reduceBy | back to summary |
|---|---|
| public default <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.
| |
| reject | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is false, that key and value are returned in a new map.
MapIterable<City, Person> rejected =
peopleByCity.reject((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| reject | back to summary |
|---|---|
| public MutableSet Redeclares org. Doc from org. Returns all elements of the source collection that return false when evaluating of the predicate. This method is also sometimes called filterNot and is the equivalent of calling iterable.select(Predicates.not(predicate)). Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.reject(person -> person.person.getLastName().equals("Smith"));
| |
| rejectWith | back to summary |
|---|---|
| public <P> MutableSet Redeclares org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> rejected =
people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
| |
| select | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. For each key and value of the map the predicate is evaluated, if the result of the evaluation is true, that key and value are returned in a new map.
MapIterable<City, Person> selected =
peopleByCity.select((city, person) -> city.getName().equals("Anytown") && person.getLastName().equals("Smith"));
| |
| select | back to summary |
|---|---|
| public MutableSet Redeclares org. Doc from org. Returns all elements of the source collection that return true when evaluating the predicate. This method is also commonly called filter. Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.select(person -> person.getAddress().getCity().equals("London"));
| |
| selectInstancesOf | back to summary |
|---|---|
| public <S> MutableSet Redeclares org. Doc from org. Returns all elements of the source collection that are instances of the Class
RichIterable<Integer> integers =
List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
| |
| selectWith | back to summary |
|---|---|
| public <P> MutableSet Redeclares org. Doc from org. Similar to
E.g. return a Example using a Java 8 lambda expression:
RichIterable<Person> selected =
people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
| |
| tap | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Executes the Procedure for each value of the map and returns return peopleByCity.tap(person -> LOGGER.info(person.getName()));
| |
| withAllKeyValueArguments | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. Convenience var-args version of withAllKeyValues
| |
| withAllKeyValues | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original plus all the additional keys and values. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withAllKeyValues(FastList.newListWith(PairImpl.of("new key", "new value")));
In the case of FixedSizeMap, a new instance will be returned by withAllKeyValues, and any variables that
previously referenced the original map will need to be redirected to reference the new instance. In the case
of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap
will both return "this" after calling put on themselves.
| |
| withKeyValue | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to add elements to their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original plus the additional key and value. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withKeyValue("new key", "new value");
In the case of FixedSizeMap, a new instance will be returned by withKeyValue, and any variables that
previously referenced the original map will need to be redirected to reference the new instance. In the case
of a FastMap or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap
will both return "this" after calling put on themselves.
| |
| withMap | back to summary |
|---|---|
| public default MutableBiMap Overrides default org. Doc from org. Similar to
| |
| withMapIterable | back to summary |
|---|---|
| public default MutableBiMap Overrides default org.
| |
| withoutAllKeys | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original minus all the keys and values to be removed. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withoutAllKeys(FastList.newListWith("key1", "key2"));
In the case of FixedSizeMap, a new instance will be returned by withoutAllKeys, and any variables that previously
referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap
or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return
"this" after calling remove on themselves.
| |
| withoutKey | back to summary |
|---|---|
| public MutableBiMap Redeclares org. Doc from org. This method allows mutable, fixed size, and immutable maps the ability to remove elements from their existing elements. In order to support fixed size maps, a new instance of a map would have to be returned including the keys and values of the original minus the key and value to be removed. In the case of mutable maps, the original map is modified and then returned. In order to use this method properly with mutable and fixed size maps the following approach must be taken:
map = map.withoutKey("key");
In the case of FixedSizeMap, a new instance will be returned by withoutKey, and any variables that previously
referenced the original map will need to be redirected to reference the new instance. In the case of a FastMap
or UnifiedMap, you will be replacing the reference to map with map, since FastMap and UnifiedMap will both return
"this" after calling remove on themselves.
| |
| zip | back to summary |
|---|---|
| public <S> MutableSet Redeclares org. Doc from org. Deprecated in 8.0. Use Returns a
| |
| zipWithIndex | back to summary |
|---|---|
| public MutableSet Redeclares org. Doc from org. Deprecated in 8.0. Use Zips this
| |