Top Description Constructors Methods
org.eclipse.collections.impl.utility

public final Class MapIterate

extends Object
Class Inheritance
Imports
java.util.Collection, .Comparator, .Map, .Objects, .Optional, org.eclipse.collections.api.RichIterable, org.eclipse.collections.api.block.function.Function, .Function0, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.collection.primitive.MutableBooleanCollection, .MutableByteCollection, .MutableCharCollection, .MutableDoubleCollection, .MutableFloatCollection, .MutableIntCollection, .MutableLongCollection, .MutableShortCollection, org.eclipse.collections.api.factory.Lists, .Maps, org.eclipse.collections.api.factory.primitive.BooleanLists, .ByteLists, .CharLists, .DoubleLists, .FloatLists, .IntLists, .LongLists, .ShortLists, org.eclipse.collections.api.list.MutableList, org.eclipse.collections.api.map.ImmutableMap, .MapIterable, .MutableMap, .UnsortedMapIterable, org.eclipse.collections.api.map.sorted.SortedMapIterable, org.eclipse.collections.api.multimap.set.MutableSetMultimap, org.eclipse.collections.api.multimap.sortedset.MutableSortedSetMultimap, org.eclipse.collections.api.tuple.Pair, org.eclipse.collections.impl.block.factory.Predicates, org.eclipse.collections.impl.block.procedure.CollectProcedure, .CollectionAddProcedure, .CountProcedure, .MapEntryToProcedure2, .MapPutProcedure, .RejectProcedure, .SelectProcedure, org.eclipse.collections.impl.factory.Multimaps, org.eclipse.collections.impl.list.mutable.FastList, org.eclipse.collections.impl.map.mutable.MapAdapter, .UnifiedMap, org.eclipse.collections.impl.multimap.set.sorted.TreeSortedSetMultimap, org.eclipse.collections.impl.tuple.AbstractImmutableEntry, .Tuples, org.eclipse.collections.impl.utility.internal.IterableIterate

The MapIterate class provides a few of the methods from the Smalltalk Collection Protocol. This includes: Since Maps have two data-points per entry (i.e. key and value), most of the implementations in this class iterates over the values only, unless otherwise specified. To iterate over the keys, use keySet() with standard Iterate methods.
Since
1.0
See Also
Iterate

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <K, V> Collection<K>
addAllKeysTo(Map<K, V> map, Collection<K> targetCollection)

Adds all the keys from map to the specified targetCollection.

public static <K, V> Collection<V>
addAllValuesTo(Map<K, V> map, Collection<V> targetCollection)

Adds all the values from map to the specified targetCollection.

public static <K, V> boolean
allSatisfy(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V> boolean
anySatisfy(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V, A> MutableList<A>
collect(Map<K, V> map, Function<? super V, ? extends A> function)

public static <K, V, K2, V2> MutableMap<K2, V2>
collect(Map<K, V> map, Function2<? super K, ? super V, Pair<K2, V2>> function)

For each value of the map, the function is evaluated with the key and value as the parameter.

public static <K1, V1, K2, V2, R extends Map<K2, V2>> R
collect(Map<K1, V1> map, Function2<? super K1, ? super V1, Pair<K2, V2>> function, R target)

For each value of the map, the function is evaluated with the key and value as the parameter.

public static <K1, V1, K2, V2> MutableMap<K2, V2>
collect(Map<K1, V1> map, Function<? super K1, ? extends K2> keyFunction, Function<? super V1, ? extends V2> valueFunction)

For each key-value entry of a map, applies a function to each, and adds the transformed entry to a new Map.

public static <K1, V1, K2, V2> MutableMap<K2, V2>
collect(Map<K1, V1> map, Function<? super K1, ? extends K2> keyFunction, Function<? super V1, ? extends V2> valueFunction, Map<K2, V2> target)

For each key-value entry of a map, applies a function to each, and adds the transformed entry to the target Map.

public static <K, V, A, R extends Collection<A>> R
collect(Map<K, V> map, Function<? super V, ? extends A> function, R targetCollection)

public static <K, V> MutableBooleanCollection
collectBoolean(Map<K, V> map, BooleanFunction<? super V> booleanFunction)

public static <K, V, R extends MutableBooleanCollection> R
collectBoolean(Map<K, V> map, BooleanFunction<? super V> booleanFunction, R target)

public static <K, V> MutableByteCollection
collectByte(Map<K, V> map, ByteFunction<? super V> byteFunction)

public static <K, V, R extends MutableByteCollection> R
collectByte(Map<K, V> map, ByteFunction<? super V> byteFunction, R target)

public static <K, V> MutableCharCollection
collectChar(Map<K, V> map, CharFunction<? super V> charFunction)

public static <K, V, R extends MutableCharCollection> R
collectChar(Map<K, V> map, CharFunction<? super V> charFunction, R target)

public static <K, V> MutableDoubleCollection
collectDouble(Map<K, V> map, DoubleFunction<? super V> doubleFunction)

public static <K, V, R extends MutableDoubleCollection> R
collectDouble(Map<K, V> map, DoubleFunction<? super V> doubleFunction, R target)

public static <K, V> MutableFloatCollection
collectFloat(Map<K, V> map, FloatFunction<? super V> floatFunction)

public static <K, V, R extends MutableFloatCollection> R
collectFloat(Map<K, V> map, FloatFunction<? super V> floatFunction, R target)

public static <K1, V1, K2, V2> MutableMap<K2, V2>
collectIf(Map<K1, V1> map, Function2<? super K1, ? super V1, Pair<K2, V2>> function, Predicate2<? super K1, ? super V1> predicate)

For each value of the map, the Predicate2 is evaluated with the key and value as the parameter, and if true, then function is applied.

public static <K1, V1, K2, V2> MutableMap<K2, V2>
collectIf(Map<K1, V1> map, Function2<? super K1, ? super V1, Pair<K2, V2>> function, Predicate2<? super K1, ? super V1> predicate, Map<K2, V2> target)

For each value of the map, the Predicate2 is evaluated with the key and value as the parameter, and if true, then function is applied.

public static <K, V> MutableIntCollection
collectInt(Map<K, V> map, IntFunction<? super V> intFunction)

public static <K, V, R extends MutableIntCollection> R
collectInt(Map<K, V> map, IntFunction<? super V> intFunction, R target)

public static <K, V, K2, R extends Map<K2, V>> R
collectKeysUnique(Map<K, V> map, Function2<? super K, ? super V, ? extends K2> function, R target)

public static <K, V> MutableLongCollection
collectLong(Map<K, V> map, LongFunction<? super V> longFunction)

public static <K, V, R extends MutableLongCollection> R
collectLong(Map<K, V> map, LongFunction<? super V> longFunction, R target)

public static <K, V> MutableShortCollection
collectShort(Map<K, V> map, ShortFunction<? super V> shortFunction)

public static <K, V, R extends MutableShortCollection> R
collectShort(Map<K, V> map, ShortFunction<? super V> shortFunction, R target)

public static <K, V, V2> MutableMap<K, V2>
collectValues(Map<K, V> map, Function2<? super K, ? super V, ? extends V2> function)

For each key and value of the map, the function is evaluated with the key and value as the parameter.

public static <K, V, V2, R extends Map<K, V2>> R
collectValues(Map<K, V> map, Function2<? super K, ? super V, ? extends V2> function, R target)

For each key and value of the map, the function is evaluated with the key and value as the parameter.

public static <K, V> int
count(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V> Pair<K, V>
detect(Map<K, V> map, Predicate2<? super K, ? super V> predicate)

public static <K, V> V
detect(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V> V
detectIfNone(Map<K, V> map, Predicate<? super V> predicate, V ifNone)

public static <K, V> Optional<Pair<K, V>>
detectOptional(Map<K, V> map, Predicate2<? super K, ? super V> predicate)

public static <K, V> Optional<V>
detectOptional(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V> MutableSetMultimap<V, K>
flip(MapIterable<K, V> iMap)

public static <K, V> MutableSortedSetMultimap<V, K>
flip(SortedMapIterable<K, V> iMap)

public static <K, V> MutableMap<V, K>
flipUniqueValues(MapIterable<K, V> mapIterable)

public static <K, V> void
forEachKey(Map<K, V> map, Procedure<? super K> procedure)

For each key of the map, procedure is evaluated with the key as the parameter.

public static <K, V> void
forEachKeyValue(Map<K, V> map, Procedure2<? super K, ? super V> procedure)

For each entry of the map, procedure is evaluated with the element as the parameter.

public static <K, V> void
forEachValue(Map<K, V> map, Procedure<? super V> procedure)

For each value of the map, procedure is evaluated with the value as the parameter.

public static <K, V> V
getIfAbsent(Map<K, V> map, K key, Function0<? extends V> instanceBlock)

Get and return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function0.

public static <K, V> V
getIfAbsentDefault(Map<K, V> map, K key, V defaultValue)

Get and return the value in the Map at the specified key, or if there is no value at the key, return the defaultValue.

public static <K, V> V
getIfAbsentPut(Map<K, V> map, K key, Function0<? extends V> instanceBlock)

Get and return the value in the Map at the specified key, or if there is no value at the key, return the result of evaluating the specified Function0, and put that value in the map at the specified key.

public static <K, V, P> V
getIfAbsentPutWith(Map<K, V> map, K key, Function<? super P, ? extends V> function, P parameter)

Get and return the value in the Map at the specified key, or if there is no value at the key, return the result of evaluating the specified Function with the parameter, and put that value in the map at the specified key.

public static <K, V, P> V
getIfAbsentWith(Map<K, V> map, K key, Function<? super P, ? extends V> function, P parameter)

Get and return the value in the Map that corresponds to the specified key, or if there is no value at the key, return the result of evaluating the specified Function with the specified parameter.

public static <K, V, A> A
ifPresentApply(Map<K, V> map, K key, Function<? super V, ? extends A> function)

If there is a value in the Map that the specified key, return the result of applying the specified Function on the value, otherwise return null.

public static <K, V, IV> IV
injectInto(IV injectValue, Map<K, V> map, Function2<? super IV, ? super V, ? extends IV> function)

public static <IV, K, V> IV
injectIntoIf(IV initialValue, Map<K, V> map, Predicate<? super V> predicate, Function2<? super IV, ? super V, ? extends IV> function)

Same as injectInto(Object, Map, Function2), but only applies the value to the function if the predicate returns true for the value.

private static <K, V> boolean
isAbsent(V result, Map<K, V> map, K key)

public static boolean
isEmpty(Map<?, ?> map)

A null-safe check on a map to see if it isEmpty.

public static <K, V> boolean
noneSatisfy(Map<K, V> map, Predicate<? super V> predicate)

public static boolean
notEmpty(Map<?, ?> map)

A null-safe check on a map to see if it notEmpty.

public static <K, V> int
occurrencesOf(Map<K, V> map, V object)

Return the number of occurrences of object in the specified map.

public static <K, V, A> int
occurrencesOfAttribute(Map<K, V> map, Function<? super V, ? extends A> function, A object)

Return the number of occurrences where object is equal to the specified attribute in the specified map.

public static <K, V> MutableList<V>
reject(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V, R extends Collection<V>> R
reject(Map<K, V> map, Predicate<? super V> predicate, R targetCollection)

public static <K, V> MutableMap<K, V>
rejectMapOnEntry(Map<K, V> map, Predicate2<? super K, ? super V> predicate)

For each value of the map, predicate is evaluated with the element as the parameter.

public static <K, V, R extends Map<K, V>> R
rejectMapOnEntry(Map<K, V> map, Predicate2<? super K, ? super V> predicate, R target)

For each value of the map, predicate is evaluated with the element as the parameter.

public static <K, V> MutableMap<V, K>
reverseMapping(Map<K, V> map)

Return a new map swapping key-value for value-key.

public static <K, V> MutableList<V>
select(Map<K, V> map, Predicate<? super V> predicate)

public static <K, V, R extends Collection<V>> R
select(Map<K, V> map, Predicate<? super V> predicate, R targetCollection)

public static <K, V> MutableMap<K, V>
selectMapOnEntry(Map<K, V> map, Predicate2<? super K, ? super V> predicate)

For each entry of the source map, the Predicate2 is evaluated.

public static <K, V, R extends Map<K, V>> R
selectMapOnEntry(Map<K, V> map, Predicate2<? super K, ? super V> predicate, R target)

For each entry of the source map, the Predicate2 is evaluated.

public static <K, V> MutableMap<K, V>
selectMapOnKey(Map<K, V> map, Predicate<? super K> predicate)

For each key of the source map, the Predicate is evaluated.

public static <K, V> MutableMap<K, V>
selectMapOnValue(Map<K, V> map, Predicate<? super V> predicate)

For each value of the source map, the Predicate is evaluated.

public static <K, V> MutableList<Pair<K, V>>
toListOfPairs(Map<K, V> map)

Iterate over the specified map applying the specified Function to each value and return the results as a List.

public static <K, V> MutableList<V>
toSortedList(Map<K, V> map, Comparator<? super V> comparator)

Iterate over the specified map applying the specified Function to each value and return the results as a sorted List using the specified Comparator.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait