Class ImmutableOrderedMapAdapter<K,V>
- All Implemented Interfaces:
Serializable, Iterable<V>, Map<K,V>, InternalIterable<V>, ImmutableMapIterable<K, V>, ImmutableOrderedMap<K, V>, MapIterable<K, V>, OrderedMap<K, V>, OrderedIterable<V>, ReversibleIterable<V>, RichIterable<V>
- See Also:
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<KK,VVV, VV>
ImmutableOrderedMap<KK, VV> aggregateBy(Function<? super K, ? extends KK> keyFunction, Function<? super V, ? extends VVV> valueFunction, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super VVV, ? extends VV> nonMutatingAggregator) Applies an aggregate function over the map grouping results into a map based on the specific key and value groupBy functions.<KK,VV> ImmutableOrderedMap <KK, VV> aggregateBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super V, ? extends VV> nonMutatingAggregator) Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.<KK,VV> ImmutableOrderedMap <KK, VV> aggregateInPlaceBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Procedure2<? super VV, ? super V> mutatingAggregator) Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.voidclear()<VV> ImmutableList<VV> Returns a new collection with the results of applying the specified function on each element of the source collection.<K2,V2> ImmutableOrderedMap <K2, V2> For each key and value of the map the function is evaluated.collectBoolean(BooleanFunction<? super V> booleanFunction) Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.collectByte(ByteFunction<? super V> byteFunction) Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.collectChar(CharFunction<? super V> charFunction) Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.collectDouble(DoubleFunction<? super V> doubleFunction) Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.collectFloat(FloatFunction<? super V> floatFunction) Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<VV> ImmutableList<VV> Returns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate.collectInt(IntFunction<? super V> intFunction) Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.<R> ImmutableOrderedMap<R, V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function) For each key and value of the map the function is evaluated.collectLong(LongFunction<? super V> longFunction) Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.collectShort(ShortFunction<? super V> shortFunction) Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<R> ImmutableOrderedMap<K, R> collectValues(Function2<? super K, ? super V, ? extends R> function) For each key and value of the map the function is evaluated.<P,VV> ImmutableList <VV> collectWith(Function2<? super V, ? super P, ? extends VV> function, P parameter) Same asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.booleancontainsKey(Object key) booleancontainsValue(Object value) <S> booleancorresponds(OrderedIterable<S> other, Predicate2<? super V, ? super S> predicate) Returns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother.<V1> ImmutableBag<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.Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.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.intdetectIndex(Predicate<? super V> predicate) Returns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true.intdetectLastIndex(Predicate<? super V> predicate) Returns the index of the last element of theReversibleIterablefor which thepredicateevaluates to true.detectOptional(Predicate<? super V> predicate) Returns the first element of the iterable for which the predicate evaluates to true as an Optional.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.distinct()Returns a newOrderedIterablecontaining the distinct elements in this iterable.drop(int count) Returns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.Returns the final elements that do not satisfy the Predicate.entrySet()booleanFollows the same general contract asMap.equals(Object).<VV> ImmutableList<VV> flatCollect(Function<? super V, ? extends Iterable<VV>> function) flatCollectis a special case ofRichIterable.collect(Function).flip()Given a map from Domain->Range return a multimap from Range->Domain.Return the MapIterable that is obtained by flipping the direction of this map and making the associations from value to key.voidIterates over the section of the iterable covered by the specified inclusive indexes.voidforEach(BiConsumer<? super K, ? super V> action) voidforEachKey(Procedure<? super K> procedure) Calls theprocedurewith each key of the map.voidforEachKeyValue(Procedure2<? super K, ? super V> procedure) Calls theprocedurewith each key-value pair of the map.voidforEachValue(Procedure<? super V> procedure) Calls the procedure with each value of the map.<P> voidforEachWith(Procedure2<? super V, ? super P> procedure, P parameter) The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.voidforEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super V> objectIntProcedure) Iterates over the section of the iterable covered by the specified inclusive indexes.voidforEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure) Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.getIfAbsent(K key, Function0<? extends V> function) 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.getIfAbsentValue(K key, V value) Return the value in the Map that corresponds to the specified key, or if there is no value at the key, returnvalue.<P> VgetIfAbsentWith(K key, Function<? super P, ? extends V> function, P parameter) 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 and parameter.<VV> ImmutableListMultimap<VV, V> 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.<VV> ImmutableListMultimap<VV, V> groupByEach(Function<? super V, ? extends Iterable<VV>> function) Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<VV> ImmutableOrderedMap<VV, V> groupByUniqueKey(Function<? super V, ? extends VV> function) 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.inthashCode()Follows the same general contract asMap.hashCode().<A> AifPresentApply(K key, Function<? super V, ? extends A> function) If there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.iterator()keySet()keysView()Returns an unmodifiable lazy iterable wrapped around the keySet for the map.RichIterable<Pair<K, V>> Returns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.newWithAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs) newWithAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) newWithKeyValue(K key, V value) newWithMap(Map<? extends K, ? extends V> map) newWithMapIterable(MapIterable<? extends K, ? extends V> mapIterable) newWithoutAllKeys(Iterable<? extends K> keys) newWithoutKey(K key) Filters a collection into a PartitionedIterable based on the evaluation of the predicate.partitionWhile(Predicate<? super V> predicate) Returns a Partition of the initial elements that satisfy the Predicate and the remaining elements.<P> PartitionImmutableList<V> partitionWith(Predicate2<? super V, ? super P> predicate, P parameter) Filters a collection into a PartitionIterable based on the evaluation of the predicate.void<KK> ImmutableOrderedMap<KK, V> reduceBy(Function<? super V, ? extends KK> groupBy, Function2<? super V, ? super V, ? extends V> reduceFunction) Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.Returns all elements of the source collection that return false when evaluating of the predicate.reject(Predicate2<? super K, ? super V> predicate) 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.<P> ImmutableList<V> rejectWith(Predicate2<? super V, ? super P> predicate, P parameter) Similar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.Returns all elements of the source collection that return true when evaluating the predicate.select(Predicate2<? super K, ? super V> predicate) 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.<S> ImmutableList<S> selectInstancesOf(Class<S> clazz) Returns all elements of the source collection that are instances of the Classclazz.<P> ImmutableList<V> selectWith(Predicate2<? super V, ? super P> predicate, P parameter) Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.intsize()Returns the number of items in this iterable.<VV> ImmutableObjectDoubleMap<VV> sumByDouble(Function<? super V, ? extends VV> groupBy, DoubleFunction<? super V> function) Groups and sums the values using the two specified functions.<VV> ImmutableObjectDoubleMap<VV> sumByFloat(Function<? super V, ? extends VV> groupBy, FloatFunction<? super V> function) Groups and sums the values using the two specified functions.<VV> ImmutableObjectLongMap<VV> sumByInt(Function<? super V, ? extends VV> groupBy, IntFunction<? super V> function) Groups and sums the values using the two specified functions.<VV> ImmutableObjectLongMap<VV> sumByLong(Function<? super V, ? extends VV> groupBy, LongFunction<? super V> function) Groups and sums the values using the two specified functions.take(int count) Returns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.Returns the initial elements that satisfy the Predicate.Executes the Procedure for each element in the iterable and returnsthis.Returns a new ReversibleIterable in reverse order.toString()Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.values()Returns an unmodifiable lazy iterable wrapped around the values for the map.<S> ImmutableList<Pair<V, S>> Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.Zips thisRichIterablewith its indices.Methods inherited from class AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, each, getFirst, getLast, getOnly, getOrDefault, isAbsent, keyAndValueEquals, keyAndValueHashCode, noneSatisfy, noneSatisfyWith, toArray, toArrayMethods inherited from class AbstractRichIterable
appendString, appendString, collect, collectIf, 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, zip, zipWithIndexMethods inherited from interface ImmutableMapIterable
countBy, countByWithMethods inherited from interface ImmutableOrderedMap
flatCollectWithMethods inherited from interface InternalIterable
forEachMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, isEmpty, merge, putIfAbsent, remove, replace, replace, replaceAllMethods inherited from interface MapIterable
getOrDefault, injectIntoKeyValue, parallelStream, spliterator, streamMethods inherited from interface OrderedIterable
collectWithIndex, getFirst, getFirstOptional, getLast, getLastOptional, indexOf, max, min, rejectWithIndex, selectWithIndex, toStack, zip, zipWithIndexMethods inherited from interface ReversibleIterable
asReversed, collectWithIndex, reverseForEach, reverseForEachWithIndexMethods inherited from interface RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detectIfNone, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, isEmpty, makeString, makeString, makeString, makeString, max, maxBy, maxByOptional, maxOptional, maxOptional, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
delegate
-
-
Constructor Details
-
ImmutableOrderedMapAdapter
-
-
Method Details
-
hashCode
public int hashCode()Description copied from interface:MapIterableFollows the same general contract asMap.hashCode(). -
equals
Description copied from interface:MapIterableFollows the same general contract asMap.equals(Object). -
toString
Description copied from class:AbstractRichIterableReturns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.Assert.assertEquals("[]", Lists.mutable.empty().toString()); Assert.assertEquals("[1]", Lists.mutable.with(1).toString()); Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());- Specified by:
toStringin interfaceMapIterable<K,V> - Specified by:
toStringin interfaceRichIterable<K>- Overrides:
toStringin classAbstractRichIterable<V>- Returns:
- a string representation of this collection.
- See Also:
-
forEach
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable. -
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Specified by:
containsKeyin interfaceMapIterable<K,V> - See Also:
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Specified by:
containsValuein interfaceMapIterable<K,V> - See Also:
-
get
-
forEachValue
Description copied from interface:MapIterableCalls the procedure with each value of the map.Set<String> result = UnifiedSet.newSet(); MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three", 4, "Four"); map.forEachValue(new CollectionAddProcedure<String>(result)); Verify.assertSetsEqual(UnifiedSet.newSetWith("One", "Two", "Three", "Four"), result);- Specified by:
forEachValuein interfaceMapIterable<K,V> - Overrides:
forEachValuein classAbstractMapIterable<K,V>
-
forEachKey
Description copied from interface:MapIterableCalls theprocedurewith each key of the map.final Collection<Integer> result = new ArrayList<Integer>(); MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "1", 2, "2", 3, "3"); map.forEachKey(new CollectionAddProcedure<Integer>(result)); Verify.assertContainsAll(result, 1, 2, 3);- Specified by:
forEachKeyin interfaceMapIterable<K,V> - Overrides:
forEachKeyin classAbstractMapIterable<K,V>
-
forEachKeyValue
Description copied from interface:MapIterableCalls theprocedurewith each key-value pair of the map.final Collection<String> collection = new ArrayList<String>(); MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three"); map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value)); Verify.assertContainsAll(collection, "1One", "2Two", "3Three");- Specified by:
forEachKeyValuein interfaceMapIterable<K,V>
-
keysView
Description copied from interface:MapIterableReturns an unmodifiable lazy iterable wrapped around the keySet for the map.- Specified by:
keysViewin interfaceMapIterable<K,V>
-
valuesView
Description copied from interface:MapIterableReturns an unmodifiable lazy iterable wrapped around the values for the map.- Specified by:
valuesViewin interfaceMapIterable<K,V>
-
keyValuesView
Description copied from interface:MapIterableReturns an unmodifiable lazy iterable of key/value pairs wrapped around the entrySet for the map.- Specified by:
keyValuesViewin interfaceMapIterable<K,V>
-
forEachWithIndex
Description copied from interface:InternalIterableIterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.Example using a Java 8 lambda:
people.forEachWithIndex((Person person, int index) -> LOGGER.info("Index: " + index + " person: " + person.getName()));Example using an anonymous inner class:
people.forEachWithIndex(new ObjectIntProcedure<Person>() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });- Specified by:
forEachWithIndexin interfaceInternalIterable<K>- Specified by:
forEachWithIndexin interfaceOrderedIterable<K>- Overrides:
forEachWithIndexin classAbstractMapIterable<K,V>
-
forEachWith
Description copied from interface:InternalIterableThe procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.Example using a Java 8 lambda:
people.forEachWith((Person person, Person other) -> { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } }, fred);Example using an anonymous inner class:
people.forEachWith(new Procedure2<Person, Person>() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);- Specified by:
forEachWithin interfaceInternalIterable<K>- Overrides:
forEachWithin classAbstractMapIterable<K,V>
-
ifPresentApply
Description copied from interface:MapIterableIf there is a value in the Map that corresponds to the specified key return the result of applying the specified Function on the value, otherwise return null.- Specified by:
ifPresentApplyin interfaceMapIterable<K,V> - Overrides:
ifPresentApplyin classAbstractMapIterable<K,V>
-
getIfAbsent
Description copied from interface:MapIterableReturn 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.- Specified by:
getIfAbsentin interfaceMapIterable<K,V> - Overrides:
getIfAbsentin classAbstractMapIterable<K,V>
-
getIfAbsentValue
Description copied from interface:MapIterableReturn the value in the Map that corresponds to the specified key, or if there is no value at the key, returnvalue.- Specified by:
getIfAbsentValuein interfaceMapIterable<K,V> - Overrides:
getIfAbsentValuein classAbstractMapIterable<K,V>
-
getIfAbsentWith
Description copied from interface:MapIterableReturn 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 and parameter.- Specified by:
getIfAbsentWithin interfaceMapIterable<K,V> - Overrides:
getIfAbsentWithin classAbstractMapIterable<K,V>
-
castToMap
-
iterator
-
putAll
-
clear
-
flip
Description copied from interface:MapIterableGiven a map from Domain->Range return a multimap from Range->Domain. We chose the name 'flip' rather than 'invert' or 'transpose' since this method does not have the property of applying twice returns the original.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.
- Specified by:
flipin interfaceImmutableMapIterable<K,V> - Specified by:
flipin interfaceImmutableOrderedMap<K,V> - Specified by:
flipin interfaceMapIterable<K,V> - Specified by:
flipin interfaceOrderedMap<K,V>
-
newWithKeyValue
- Specified by:
newWithKeyValuein interfaceImmutableMapIterable<K,V> - Specified by:
newWithKeyValuein interfaceImmutableOrderedMap<K,V>
-
newWithAllKeyValues
public ImmutableOrderedMap<K,V> newWithAllKeyValues(Iterable<? extends Pair<? extends K, ? extends V>> keyValues) - Specified by:
newWithAllKeyValuesin interfaceImmutableMapIterable<K,V> - Specified by:
newWithAllKeyValuesin interfaceImmutableOrderedMap<K,V>
-
newWithMap
- Specified by:
newWithMapin interfaceImmutableMapIterable<K,V> - Specified by:
newWithMapin interfaceImmutableOrderedMap<K,V>
-
newWithMapIterable
public ImmutableOrderedMap<K,V> newWithMapIterable(MapIterable<? extends K, ? extends V> mapIterable) - Specified by:
newWithMapIterablein interfaceImmutableMapIterable<K,V> - Specified by:
newWithMapIterablein interfaceImmutableOrderedMap<K,V>
-
newWithAllKeyValueArguments
public ImmutableOrderedMap<K,V> newWithAllKeyValueArguments(Pair<? extends K, ? extends V>... keyValuePairs) - Specified by:
newWithAllKeyValueArgumentsin interfaceImmutableMapIterable<K,V> - Specified by:
newWithAllKeyValueArgumentsin interfaceImmutableOrderedMap<K,V>
-
newWithoutKey
- Specified by:
newWithoutKeyin interfaceImmutableMapIterable<K,V> - Specified by:
newWithoutKeyin interfaceImmutableOrderedMap<K,V>
-
newWithoutAllKeys
- Specified by:
newWithoutAllKeysin interfaceImmutableMapIterable<K,V> - Specified by:
newWithoutAllKeysin interfaceImmutableOrderedMap<K,V>
-
put
-
remove
-
flipUniqueValues
Description copied from interface:MapIterableReturn 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)));- Specified by:
flipUniqueValuesin interfaceImmutableMapIterable<K,V> - Specified by:
flipUniqueValuesin interfaceImmutableOrderedMap<K,V> - Specified by:
flipUniqueValuesin interfaceMapIterable<K,V> - Specified by:
flipUniqueValuesin interfaceOrderedMap<K,V>
-
collect
public <K2,V2> ImmutableOrderedMap<K2,V2> collect(Function2<? super K, ? super V, Pair<K2, V2>> function) Description copied from interface:MapIterableFor 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()));- Specified by:
collectin interfaceImmutableMapIterable<K,V> - Specified by:
collectin interfaceImmutableOrderedMap<K,V> - Specified by:
collectin interfaceMapIterable<K,V> - Specified by:
collectin interfaceOrderedMap<K,V>
-
collectValues
public <R> ImmutableOrderedMap<K,R> collectValues(Function2<? super K, ? super V, ? extends R> function) Description copied from interface:MapIterableFor 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());- Specified by:
collectValuesin interfaceImmutableMapIterable<K,V> - Specified by:
collectValuesin interfaceImmutableOrderedMap<K,V> - Specified by:
collectValuesin interfaceMapIterable<K,V> - Specified by:
collectValuesin interfaceOrderedMap<K,V>
-
collectKeysUnique
public <R> ImmutableOrderedMap<R,V> collectKeysUnique(Function2<? super K, ? super V, ? extends R> function) Description copied from interface:MapIterableFor 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.- Specified by:
collectKeysUniquein interfaceImmutableMapIterable<K,V> - Specified by:
collectKeysUniquein interfaceImmutableOrderedMap<K,V> - Specified by:
collectKeysUniquein interfaceMapIterable<K,V>
-
select
Description copied from interface:MapIterableFor 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"));- Specified by:
selectin interfaceImmutableMapIterable<K,V> - Specified by:
selectin interfaceImmutableOrderedMap<K,V> - Specified by:
selectin interfaceMapIterable<K,V> - Specified by:
selectin interfaceOrderedMap<K,V>
-
reject
Description copied from interface:MapIterableFor 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"));- Specified by:
rejectin interfaceImmutableMapIterable<K,V> - Specified by:
rejectin interfaceImmutableOrderedMap<K,V> - Specified by:
rejectin interfaceMapIterable<K,V> - Specified by:
rejectin interfaceOrderedMap<K,V>
-
detect
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detect(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));- Specified by:
detectin interfaceRichIterable<K>- Overrides:
detectin classAbstractMapIterable<K,V>
-
detectOptional
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true as an Optional. This method is commonly called find.Example using a Java 8 lambda expression:
Person person = people.detectOptional(person -> person.getFirstName().equals("John") && person.getLastName().equals("Smith"));- Specified by:
detectOptionalin interfaceRichIterable<K>- Overrides:
detectOptionalin classAbstractMapIterable<K,V>
-
collect
Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
RichIterable<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName());- Specified by:
collectin interfaceImmutableOrderedMap<K,V> - Specified by:
collectin interfaceOrderedIterable<K>- Specified by:
collectin interfaceOrderedMap<K,V> - Specified by:
collectin interfaceReversibleIterable<K>- Specified by:
collectin interfaceRichIterable<K>
-
collectWith
public <P,VV> ImmutableList<VV> collectWith(Function2<? super V, ? super P, ? extends VV> function, P parameter) Description copied from interface:RichIterableSame asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.Example using a Java 8 lambda expression:
RichIterable<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1));- Specified by:
collectWithin interfaceImmutableOrderedMap<K,V> - Specified by:
collectWithin interfaceOrderedIterable<K>- Specified by:
collectWithin interfaceOrderedMap<K,V> - Specified by:
collectWithin interfaceReversibleIterable<K>- Specified by:
collectWithin interfaceRichIterable<K>- Parameters:
function- AFunction2to use as the collect transformation functionparameter- A parameter to pass in for evaluation of the second argumentPinfunction- Returns:
- A new
RichIterablethat contains the transformed elements returned byFunction2.value(Object, Object) - See Also:
-
collectBoolean
Description copied from interface:RichIterableReturns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
BooleanIterable licenses = people.collectBoolean(person -> person.hasDrivingLicense());- Specified by:
collectBooleanin interfaceImmutableOrderedMap<K,V> - Specified by:
collectBooleanin interfaceOrderedIterable<K>- Specified by:
collectBooleanin interfaceOrderedMap<K,V> - Specified by:
collectBooleanin interfaceReversibleIterable<K>- Specified by:
collectBooleanin interfaceRichIterable<K>
-
collectByte
Description copied from interface:RichIterableReturns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ByteIterable bytes = people.collectByte(person -> person.getCode());- Specified by:
collectBytein interfaceImmutableOrderedMap<K,V> - Specified by:
collectBytein interfaceOrderedIterable<K>- Specified by:
collectBytein interfaceOrderedMap<K,V> - Specified by:
collectBytein interfaceReversibleIterable<K>- Specified by:
collectBytein interfaceRichIterable<K>
-
collectChar
Description copied from interface:RichIterableReturns a new primitivechariterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
CharIterable chars = people.collectChar(person -> person.getMiddleInitial());- Specified by:
collectCharin interfaceImmutableOrderedMap<K,V> - Specified by:
collectCharin interfaceOrderedIterable<K>- Specified by:
collectCharin interfaceOrderedMap<K,V> - Specified by:
collectCharin interfaceReversibleIterable<K>- Specified by:
collectCharin interfaceRichIterable<K>
-
collectDouble
Description copied from interface:RichIterableReturns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
DoubleIterable doubles = people.collectDouble(person -> person.getMilesFromNorthPole());- Specified by:
collectDoublein interfaceImmutableOrderedMap<K,V> - Specified by:
collectDoublein interfaceOrderedIterable<K>- Specified by:
collectDoublein interfaceOrderedMap<K,V> - Specified by:
collectDoublein interfaceReversibleIterable<K>- Specified by:
collectDoublein interfaceRichIterable<K>
-
collectFloat
Description copied from interface:RichIterableReturns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
FloatIterable floats = people.collectFloat(person -> person.getHeightInInches());- Specified by:
collectFloatin interfaceImmutableOrderedMap<K,V> - Specified by:
collectFloatin interfaceOrderedIterable<K>- Specified by:
collectFloatin interfaceOrderedMap<K,V> - Specified by:
collectFloatin interfaceReversibleIterable<K>- Specified by:
collectFloatin interfaceRichIterable<K>
-
collectInt
Description copied from interface:RichIterableReturns a new primitiveintiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
IntIterable ints = people.collectInt(person -> person.getAge());- Specified by:
collectIntin interfaceImmutableOrderedMap<K,V> - Specified by:
collectIntin interfaceOrderedIterable<K>- Specified by:
collectIntin interfaceOrderedMap<K,V> - Specified by:
collectIntin interfaceReversibleIterable<K>- Specified by:
collectIntin interfaceRichIterable<K>
-
collectLong
Description copied from interface:RichIterableReturns a new primitivelongiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
LongIterable longs = people.collectLong(person -> person.getGuid());- Specified by:
collectLongin interfaceImmutableOrderedMap<K,V> - Specified by:
collectLongin interfaceOrderedIterable<K>- Specified by:
collectLongin interfaceOrderedMap<K,V> - Specified by:
collectLongin interfaceReversibleIterable<K>- Specified by:
collectLongin interfaceRichIterable<K>
-
collectShort
Description copied from interface:RichIterableReturns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection. This method is also commonly called transform or map.Example using a Java 8 lambda expression:
ShortIterable shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth());- Specified by:
collectShortin interfaceImmutableOrderedMap<K,V> - Specified by:
collectShortin interfaceOrderedIterable<K>- Specified by:
collectShortin interfaceOrderedMap<K,V> - Specified by:
collectShortin interfaceReversibleIterable<K>- Specified by:
collectShortin interfaceRichIterable<K>
-
collectIf
public <VV> ImmutableList<VV> collectIf(Predicate<? super V> predicate, Function<? super V, ? extends VV> function) Description copied from interface:RichIterableReturns a new collection with the results of applying the specified function on each element of the source collection, but only for those elements which return true upon evaluation of the predicate. This is the optimized equivalent of calling iterable.select(predicate).collect(function).Example using a Java 8 lambda and method reference:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(e -> e != null, Object::toString);
Example using Predicates factory:
RichIterable<String> strings = Lists.mutable.with(1, 2, 3).collectIf(Predicates.notNull(), Functions.getToString());
- Specified by:
collectIfin interfaceImmutableOrderedMap<K,V> - Specified by:
collectIfin interfaceOrderedIterable<K>- Specified by:
collectIfin interfaceOrderedMap<K,V> - Specified by:
collectIfin interfaceReversibleIterable<K>- Specified by:
collectIfin interfaceRichIterable<K>
-
flatCollect
Description copied from interface:RichIterableflatCollectis a special case ofRichIterable.collect(Function). Withcollect, when theFunctionreturns a collection, the result is a collection of collections.flatCollectoutputs a single "flattened" collection instead. This method is commonly called flatMap.Consider the following example where we have a
Personclass, and eachPersonhas a list ofAddressobjects. Take the followingFunction:Function<Person, List<Address>> addressFunction = Person::getAddresses; RichIterable<Person> people = ...;
Usingcollectreturns a collection of collections of addresses.RichIterable<List<Address>> addresses = people.collect(addressFunction);
UsingflatCollectreturns a single flattened list of addresses.RichIterable<Address> addresses = people.flatCollect(addressFunction);
- Specified by:
flatCollectin interfaceImmutableOrderedMap<K,V> - Specified by:
flatCollectin interfaceOrderedIterable<K>- Specified by:
flatCollectin interfaceOrderedMap<K,V> - Specified by:
flatCollectin interfaceReversibleIterable<K>- Specified by:
flatCollectin interfaceRichIterable<K>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
select
Description copied from interface:RichIterableReturns 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"));- Specified by:
selectin interfaceImmutableMapIterable<K,V> - Specified by:
selectin interfaceImmutableOrderedMap<K,V> - Specified by:
selectin interfaceOrderedIterable<K>- Specified by:
selectin interfaceOrderedMap<K,V> - Specified by:
selectin interfaceReversibleIterable<K>- Specified by:
selectin interfaceRichIterable<K>
-
selectWith
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));- Specified by:
selectWithin interfaceImmutableMapIterable<K,V> - Specified by:
selectWithin interfaceImmutableOrderedMap<K,V> - Specified by:
selectWithin interfaceOrderedIterable<K>- Specified by:
selectWithin interfaceOrderedMap<K,V> - Specified by:
selectWithin interfaceReversibleIterable<K>- Specified by:
selectWithin interfaceRichIterable<K>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
reject
Description copied from interface:RichIterableReturns 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"));- Specified by:
rejectin interfaceImmutableMapIterable<K,V> - Specified by:
rejectin interfaceImmutableOrderedMap<K,V> - Specified by:
rejectin interfaceOrderedIterable<K>- Specified by:
rejectin interfaceOrderedMap<K,V> - Specified by:
rejectin interfaceReversibleIterable<K>- Specified by:
rejectin interfaceRichIterable<K>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
rejectWith
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.E.g. return a
Collectionof Person elements where the person has an age greater than or equal to 18 yearsExample using a Java 8 lambda expression:
RichIterable<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));- Specified by:
rejectWithin interfaceImmutableMapIterable<K,V> - Specified by:
rejectWithin interfaceImmutableOrderedMap<K,V> - Specified by:
rejectWithin interfaceOrderedIterable<K>- Specified by:
rejectWithin interfaceOrderedMap<K,V> - Specified by:
rejectWithin interfaceReversibleIterable<K>- Specified by:
rejectWithin interfaceRichIterable<K>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
-
partition
Description copied from interface:RichIterableFilters 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"));- Specified by:
partitionin interfaceImmutableMapIterable<K,V> - Specified by:
partitionin interfaceImmutableOrderedMap<K,V> - Specified by:
partitionin interfaceOrderedIterable<K>- Specified by:
partitionin interfaceOrderedMap<K,V> - Specified by:
partitionin interfaceReversibleIterable<K>- Specified by:
partitionin interfaceRichIterable<K>
-
partitionWith
public <P> PartitionImmutableList<V> partitionWith(Predicate2<? super V, ? super P> predicate, P parameter) Description copied from interface:RichIterableFilters 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");- Specified by:
partitionWithin interfaceImmutableOrderedMap<K,V> - Specified by:
partitionWithin interfaceOrderedIterable<K>- Specified by:
partitionWithin interfaceOrderedMap<K,V> - Specified by:
partitionWithin interfaceReversibleIterable<K>- Specified by:
partitionWithin interfaceRichIterable<K>
-
selectInstancesOf
Description copied from interface:RichIterableReturns all elements of the source collection that are instances of the Classclazz.RichIterable<Integer> integers = List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);- Specified by:
selectInstancesOfin interfaceImmutableMapIterable<K,V> - Specified by:
selectInstancesOfin interfaceImmutableOrderedMap<K,V> - Specified by:
selectInstancesOfin interfaceOrderedIterable<K>- Specified by:
selectInstancesOfin interfaceOrderedMap<K,V> - Specified by:
selectInstancesOfin interfaceReversibleIterable<K>- Specified by:
selectInstancesOfin interfaceRichIterable<K>
-
tap
Description copied from interface:RichIterableExecutes the Procedure for each element in the iterable and returnsthis.Example using a Java 8 lambda expression:
RichIterable<Person> tapped = people.tap(person -> LOGGER.info(person.getName()));- Specified by:
tapin interfaceImmutableMapIterable<K,V> - Specified by:
tapin interfaceImmutableOrderedMap<K,V> - Specified by:
tapin interfaceMapIterable<K,V> - Specified by:
tapin interfaceOrderedIterable<K>- Specified by:
tapin interfaceOrderedMap<K,V> - Specified by:
tapin interfaceReversibleIterable<K>- Specified by:
tapin interfaceRichIterable<K>- See Also:
-
zip
Description copied from interface:RichIterableReturns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs. If one of the twoRichIterables is longer than the other, its remaining elements are ignored.- Specified by:
zipin interfaceImmutableMapIterable<K,V> - Specified by:
zipin interfaceImmutableOrderedMap<K,V> - Specified by:
zipin interfaceOrderedIterable<K>- Specified by:
zipin interfaceOrderedMap<K,V> - Specified by:
zipin interfaceReversibleIterable<K>- Specified by:
zipin interfaceRichIterable<K>- Type Parameters:
S- the type of the second half of the returned pairs- Parameters:
that- TheRichIterableproviding the second half of each result pair- Returns:
- A new
RichIterablecontaining pairs consisting of corresponding elements of thisRichIterableand that. The length of the returnedRichIterableis the minimum of the lengths of thisRichIterableand that.
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceImmutableMapIterable<K,V> - Specified by:
zipWithIndexin interfaceImmutableOrderedMap<K,V> - Specified by:
zipWithIndexin interfaceOrderedIterable<K>- Specified by:
zipWithIndexin interfaceOrderedMap<K,V> - Specified by:
zipWithIndexin interfaceReversibleIterable<K>- Specified by:
zipWithIndexin interfaceRichIterable<K>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
-
groupBy
Description copied from interface:RichIterableFor 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);- Specified by:
groupByin interfaceImmutableMapIterable<K,V> - Specified by:
groupByin interfaceImmutableOrderedMap<K,V> - Specified by:
groupByin interfaceOrderedIterable<K>- Specified by:
groupByin interfaceOrderedMap<K,V> - Specified by:
groupByin interfaceReversibleIterable<K>- Specified by:
groupByin interfaceRichIterable<K>
-
groupByEach
public <VV> ImmutableListMultimap<VV,V> groupByEach(Function<? super V, ? extends Iterable<VV>> function) Description copied from interface:RichIterableSimilar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.- Specified by:
groupByEachin interfaceImmutableMapIterable<K,V> - Specified by:
groupByEachin interfaceImmutableOrderedMap<K,V> - Specified by:
groupByEachin interfaceOrderedIterable<K>- Specified by:
groupByEachin interfaceOrderedMap<K,V> - Specified by:
groupByEachin interfaceReversibleIterable<K>- Specified by:
groupByEachin interfaceRichIterable<K>
-
groupByUniqueKey
Description copied from interface:RichIterableFor 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.- Specified by:
groupByUniqueKeyin interfaceImmutableMapIterable<K,V> - Specified by:
groupByUniqueKeyin interfaceImmutableOrderedMap<K,V> - Specified by:
groupByUniqueKeyin interfaceOrderedMap<K,V> - Specified by:
groupByUniqueKeyin interfaceRichIterable<K>- See Also:
-
aggregateInPlaceBy
public <KK,VV> ImmutableOrderedMap<KK,VV> aggregateInPlaceBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Procedure2<? super VV, ? super V> mutatingAggregator) Description copied from interface:RichIterableApplies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function. Aggregate results are required to be mutable as they will be changed in place by the procedure. A second function specifies the initial "zero" aggregate value to work with (i.e. new AtomicInteger(0)).- Specified by:
aggregateInPlaceByin interfaceImmutableMapIterable<K,V> - Specified by:
aggregateInPlaceByin interfaceImmutableOrderedMap<K,V> - Specified by:
aggregateInPlaceByin interfaceRichIterable<K>
-
aggregateBy
public <KK,VV> ImmutableOrderedMap<KK,VV> aggregateBy(Function<? super V, ? extends KK> groupBy, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super V, ? extends VV> nonMutatingAggregator) Description copied from interface:RichIterableApplies 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)).- Specified by:
aggregateByin interfaceImmutableMapIterable<K,V> - Specified by:
aggregateByin interfaceImmutableOrderedMap<K,V> - Specified by:
aggregateByin interfaceRichIterable<K>
-
aggregateBy
public <KK,VVV, ImmutableOrderedMap<KK,VV> VV> aggregateBy(Function<? super K, ? extends KK> keyFunction, Function<? super V, ? extends VVV> valueFunction, Function0<? extends VV> zeroValueFactory, Function2<? super VV, ? super VVV, ? extends VV> nonMutatingAggregator) Description copied from interface:MapIterableApplies 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);- Specified by:
aggregateByin interfaceImmutableMapIterable<K,V> - Specified by:
aggregateByin interfaceImmutableOrderedMap<K,V> - Specified by:
aggregateByin interfaceMapIterable<K,V>
-
reduceBy
public <KK> ImmutableOrderedMap<KK,V> reduceBy(Function<? super V, ? extends KK> groupBy, Function2<? super V, ? super V, ? extends V> reduceFunction) Description copied from interface:RichIterableApplies 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.- Specified by:
reduceByin interfaceImmutableMapIterable<K,V> - Specified by:
reduceByin interfaceImmutableOrderedMap<K,V> - Specified by:
reduceByin interfaceRichIterable<K>
-
sumByInt
public <VV> ImmutableObjectLongMap<VV> sumByInt(Function<? super V, ? extends VV> groupBy, IntFunction<? super V> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByIntin interfaceImmutableOrderedMap<K,V> - Specified by:
sumByIntin interfaceRichIterable<K>
-
sumByFloat
public <VV> ImmutableObjectDoubleMap<VV> sumByFloat(Function<? super V, ? extends VV> groupBy, FloatFunction<? super V> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByFloatin interfaceImmutableOrderedMap<K,V> - Specified by:
sumByFloatin interfaceRichIterable<K>
-
sumByLong
public <VV> ImmutableObjectLongMap<VV> sumByLong(Function<? super V, ? extends VV> groupBy, LongFunction<? super V> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByLongin interfaceImmutableOrderedMap<K,V> - Specified by:
sumByLongin interfaceRichIterable<K>
-
sumByDouble
public <VV> ImmutableObjectDoubleMap<VV> sumByDouble(Function<? super V, ? extends VV> groupBy, DoubleFunction<? super V> function) Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByDoublein interfaceImmutableOrderedMap<K,V> - Specified by:
sumByDoublein interfaceRichIterable<K>
-
toReversed
Description copied from interface:ReversibleIterableReturns a new ReversibleIterable in reverse order.- Specified by:
toReversedin interfaceImmutableOrderedMap<K,V> - Specified by:
toReversedin interfaceOrderedMap<K,V> - Specified by:
toReversedin interfaceReversibleIterable<K>
-
take
Description copied from interface:ReversibleIterableReturns the firstcountelements of the iterable or all the elements in the iterable ifcountis greater than the length of the iterable.- Specified by:
takein interfaceImmutableOrderedMap<K,V> - Specified by:
takein interfaceOrderedMap<K,V> - Specified by:
takein interfaceReversibleIterable<K>- Parameters:
count- the number of items to take.
-
takeWhile
Description copied from interface:ReversibleIterableReturns the initial elements that satisfy the Predicate. Short circuits at the first element which does not satisfy the Predicate.- Specified by:
takeWhilein interfaceImmutableOrderedMap<K,V> - Specified by:
takeWhilein interfaceOrderedIterable<K>- Specified by:
takeWhilein interfaceOrderedMap<K,V> - Specified by:
takeWhilein interfaceReversibleIterable<K>
-
drop
Description copied from interface:ReversibleIterableReturns an iterable after skipping the firstcountelements or an empty iterable if thecountis greater than the length of the iterable.- Specified by:
dropin interfaceImmutableOrderedMap<K,V> - Specified by:
dropin interfaceOrderedMap<K,V> - Specified by:
dropin interfaceReversibleIterable<K>- Parameters:
count- the number of items to drop.
-
dropWhile
Description copied from interface:ReversibleIterableReturns the final elements that do not satisfy the Predicate. Short circuits at the first element which does satisfy the Predicate.- Specified by:
dropWhilein interfaceImmutableOrderedMap<K,V> - Specified by:
dropWhilein interfaceOrderedIterable<K>- Specified by:
dropWhilein interfaceOrderedMap<K,V> - Specified by:
dropWhilein interfaceReversibleIterable<K>
-
partitionWhile
Description copied from interface:OrderedIterableReturns a Partition of the initial elements that satisfy the Predicate and the remaining elements. Short circuits at the first element which does satisfy the Predicate.- Specified by:
partitionWhilein interfaceImmutableOrderedMap<K,V> - Specified by:
partitionWhilein interfaceOrderedIterable<K>- Specified by:
partitionWhilein interfaceOrderedMap<K,V> - Specified by:
partitionWhilein interfaceReversibleIterable<K>
-
distinct
Description copied from interface:OrderedIterableReturns a newOrderedIterablecontaining the distinct elements in this iterable.Conceptually similar to
RichIterable.toSet().RichIterable.toList()but retains the original order. If an element appears multiple times in this iterable, the first one will be copied into the result.- Specified by:
distinctin interfaceImmutableOrderedMap<K,V> - Specified by:
distinctin interfaceOrderedIterable<K>- Specified by:
distinctin interfaceOrderedMap<K,V> - Specified by:
distinctin interfaceReversibleIterable<K>- Returns:
OrderedIterableof distinct elements
-
toImmutable
- Specified by:
toImmutablein interfaceMapIterable<K,V> - Specified by:
toImmutablein interfaceOrderedMap<K,V>
-
detect
Description copied from interface:MapIterableReturn 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"));- Specified by:
detectin interfaceMapIterable<K,V>
-
detectOptional
Description copied from interface:MapIterableReturn 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"));- Specified by:
detectOptionalin interfaceMapIterable<K,V>
-
detectIndex
Description copied from interface:OrderedIterableReturns the index of the first element of theOrderedIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectIndexin interfaceOrderedIterable<K>
-
detectLastIndex
Description copied from interface:ReversibleIterableReturns the index of the last element of theReversibleIterablefor which thepredicateevaluates to true. Returns -1 if no element evaluates true for thepredicate.- Specified by:
detectLastIndexin interfaceReversibleIterable<K>
-
corresponds
public <S> boolean corresponds(OrderedIterable<S> other, Predicate2<? super V, ? super S> predicate) Description copied from interface:OrderedIterableReturns true if both OrderedIterables have the same length andpredicatereturns true for all corresponding elements e1 of thisOrderedIterableand e2 ofother. Thepredicateis evaluated for each element at the same position of eachOrderedIterablein a forward iteration order. This is a short circuit pattern.- Specified by:
correspondsin interfaceOrderedIterable<K>
-
forEach
Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<Person> people = FastList.newListWith(ted, mary, bob, sally) people.forEach(0, 1, person -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachin interfaceOrderedIterable<K>
-
forEachWithIndex
public void forEachWithIndex(int fromIndex, int toIndex, ObjectIntProcedure<? super V> objectIntProcedure) Description copied from interface:OrderedIterableIterates over the section of the iterable covered by the specified inclusive indexes. The indexes are both inclusive.e.g. OrderedIterable<People> people = FastList.newListWith(ted, mary, bob, sally) people.forEachWithIndex(0, 1, (person, index) -> LOGGER.info(person.getName()));
This code would output ted and mary's names.
- Specified by:
forEachWithIndexin interfaceOrderedIterable<K>
-
countByEach
Description copied from interface:RichIterableThis method will count the number of occurrences of each value calculated by applying the function to each element of the collection.- Specified by:
countByEachin interfaceImmutableMapIterable<K,V> - Specified by:
countByEachin interfaceRichIterable<K>- Overrides:
countByEachin classAbstractRichIterable<V>
-
keySet
-
values
-
entrySet
-