Class UnmodifiableRichIterable<T>
- java.lang.Object
-
- org.eclipse.collections.impl.UnmodifiableRichIterable<T>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<T>,InternalIterable<T>,RichIterable<T>
public class UnmodifiableRichIterable<T> extends java.lang.Object implements RichIterable<T>, java.io.Serializable
An unmodifiable view of a RichIterable.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected RichIterable<T>iterableprivate static longserialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description protectedUnmodifiableRichIterable(RichIterable<T> richIterable)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <K,V>
MapIterable<K,V>aggregateBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> nonMutatingAggregator)Applies an aggregate function over the iterable grouping results into a map based on the specific groupBy function.<K,V>
MapIterable<K,V>aggregateInPlaceBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> mutatingAggregator)Applies an aggregate procedure over the iterable grouping results into a Map based on the specific groupBy function.booleanallSatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.<P> booleanallSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to true for every element of the collection, or returns false.booleananySatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to true for any element of the iterable.<P> booleananySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to true for any element of the collection, or return false.voidappendString(java.lang.Appendable appendable)Prints a string representation of this collection onto the givenAppendable.voidappendString(java.lang.Appendable appendable, java.lang.String separator)Prints a string representation of this collection onto the givenAppendable.voidappendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Prints a string representation of this collection onto the givenAppendable.LazyIterable<T>asLazy()Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).RichIterable<RichIterable<T>>chunk(int size)Partitions elements in fixed size chunks.<V> RichIterable<V>collect(Function<? super T,? extends V> function)Returns a new collection with the results of applying the specified function on each element of the source collection.<V,R extends java.util.Collection<V>>
Rcollect(Function<? super T,? extends V> function, R target)Same asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.BooleanIterablecollectBoolean(BooleanFunction<? super T> booleanFunction)Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.<R extends MutableBooleanCollection>
RcollectBoolean(BooleanFunction<? super T> booleanFunction, R target)Same asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.ByteIterablecollectByte(ByteFunction<? super T> byteFunction)Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.<R extends MutableByteCollection>
RcollectByte(ByteFunction<? super T> byteFunction, R target)Same asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.CharIterablecollectChar(CharFunction<? super T> charFunction)Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.<R extends MutableCharCollection>
RcollectChar(CharFunction<? super T> charFunction, R target)Same asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.DoubleIterablecollectDouble(DoubleFunction<? super T> doubleFunction)Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.<R extends MutableDoubleCollection>
RcollectDouble(DoubleFunction<? super T> doubleFunction, R target)Same asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.FloatIterablecollectFloat(FloatFunction<? super T> floatFunction)Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<R extends MutableFloatCollection>
RcollectFloat(FloatFunction<? super T> floatFunction, R target)Same asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.<V> RichIterable<V>collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function)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.<V,R extends java.util.Collection<V>>
RcollectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function, R target)Same as the collectIf method with two parameters but uses the specified target collection for the results.IntIterablecollectInt(IntFunction<? super T> intFunction)Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.<R extends MutableIntCollection>
RcollectInt(IntFunction<? super T> intFunction, R target)Same asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.LongIterablecollectLong(LongFunction<? super T> longFunction)Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.<R extends MutableLongCollection>
RcollectLong(LongFunction<? super T> longFunction, R target)Same asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.ShortIterablecollectShort(ShortFunction<? super T> shortFunction)Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<R extends MutableShortCollection>
RcollectShort(ShortFunction<? super T> shortFunction, R target)Same asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.<P,V>
RichIterable<V>collectWith(Function2<? super T,? super P,? extends V> function, P parameter)Same asRichIterable.collect(Function)with aFunction2and specified parameter which is passed to the block.<P,V,R extends java.util.Collection<V>>
RcollectWith(Function2<? super T,? super P,? extends V> function, P parameter, R targetCollection)Same as collectWith but with a targetCollection parameter to gather the results.booleancontains(java.lang.Object object)Returns true if the iterable has an element which responds true to element.equals(object).booleancontainsAll(java.util.Collection<?> source)Returns true if all elements in source are contained in this collection.booleancontainsAllArguments(java.lang.Object... elements)Returns true if all elements in the specified var arg array are contained in this collection.booleancontainsAllIterable(java.lang.Iterable<?> source)Returns true if all elements in source are contained in this collection.intcount(Predicate<? super T> predicate)Return the total number of elements that answer true to the specified predicate.<P> intcountWith(Predicate2<? super T,? super P> predicate, P parameter)Returns the total number of elements that evaluate to true for the specified predicate.Tdetect(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.TdetectIfNone(Predicate<? super T> predicate, Function0<? extends T> function)Returns the first element of the iterable for which the predicate evaluates to true.java.util.Optional<T>detectOptional(Predicate<? super T> predicate)Returns the first element of the iterable for which the predicate evaluates to true as an Optional.<P> TdetectWith(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.<P> TdetectWithIfNone(Predicate2<? super T,? super P> predicate, P parameter, Function0<? extends T> function)Returns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.<P> java.util.Optional<T>detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)Returns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.voideach(Procedure<? super T> procedure)The procedure is executed for each element in the iterable.<V> RichIterable<V>flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)flatCollectis a special case ofRichIterable.collect(Function).<V,R extends java.util.Collection<V>>
RflatCollect(Function<? super T,? extends java.lang.Iterable<V>> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableBooleanCollection>
RflatCollectBoolean(Function<? super T,? extends BooleanIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableByteCollection>
RflatCollectByte(Function<? super T,? extends ByteIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableCharCollection>
RflatCollectChar(Function<? super T,? extends CharIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableDoubleCollection>
RflatCollectDouble(Function<? super T,? extends DoubleIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableFloatCollection>
RflatCollectFloat(Function<? super T,? extends FloatIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableIntCollection>
RflatCollectInt(Function<? super T,? extends IntIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableLongCollection>
RflatCollectLong(Function<? super T,? extends LongIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<R extends MutableShortCollection>
RflatCollectShort(Function<? super T,? extends ShortIterable> function, R target)Same as flatCollect, only the results are collected into the target collection.<P> voidforEachWith(Procedure2<? super T,? 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(ObjectIntProcedure<? super T> objectIntProcedure)Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.TgetFirst()Returns the first element of an iterable.TgetLast()Returns the last element of an iterable.TgetOnly()Returns the element if the iterable has exactly one element.<V> Multimap<V,T>groupBy(Function<? super T,? extends V> function)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.<V,R extends MutableMultimap<V,T>>
RgroupBy(Function<? super T,? extends V> function, R target)Same asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.<V> Multimap<V,T>groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function)Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<V,R extends MutableMultimap<V,T>>
RgroupByEach(Function<? super T,? extends java.lang.Iterable<V>> function, R target)Same asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.<V> MapIterable<V,T>groupByUniqueKey(Function<? super T,? extends V> 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.<V,R extends MutableMapIterable<V,T>>
RgroupByUniqueKey(Function<? super T,? extends V> function, R target)Same asRichIterable.groupByUniqueKey(Function), except that the results are gathered into the specifiedtargetmap.doubleinjectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function)Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.floatinjectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function)Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.intinjectInto(int injectedValue, IntObjectToIntFunction<? super T> function)Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.longinjectInto(long injectedValue, LongObjectToLongFunction<? super T> function)Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<IV> IVinjectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.<R extends java.util.Collection<T>>
Rinto(R target)Adds all the elements in this iterable to the specific target Collection.booleanisEmpty()Returns true if this iterable has zero items.java.util.Iterator<T>iterator()java.lang.StringmakeString()Returns a string representation of this collection by delegating toRichIterable.makeString(String)and defaulting the separator parameter to the characters", "(comma and space).java.lang.StringmakeString(java.lang.String separator)Returns a string representation of this collection by delegating toRichIterable.makeString(String, String, String)and defaulting the start and end parameters to""(the empty String).java.lang.StringmakeString(java.lang.String start, java.lang.String separator, java.lang.String end)Returns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.Tmax()Returns the maximum element out of this container based on the natural order.Tmax(java.util.Comparator<? super T> comparator)Returns the maximum element out of this container based on the comparator.<V extends java.lang.Comparable<? super V>>
TmaxBy(Function<? super T,? extends V> function)Returns the maximum elements out of this container based on the natural order of the attribute returned by Function.Tmin()Returns the minimum element out of this container based on the natural order.Tmin(java.util.Comparator<? super T> comparator)Returns the minimum element out of this container based on the comparator.<V extends java.lang.Comparable<? super V>>
TminBy(Function<? super T,? extends V> function)Returns the minimum elements out of this container based on the natural order of the attribute returned by Function.booleannoneSatisfy(Predicate<? super T> predicate)Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.<P> booleannoneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)Returns true if the predicate evaluates to false for every element of the collection, or return false.booleannotEmpty()The English equivalent of !this.isEmpty()static <E,RI extends RichIterable<E>>
UnmodifiableRichIterable<E>of(RI iterable)This method will take a RichIterable and wrap it directly in a UnmodifiableRichIterable.PartitionIterable<T>partition(Predicate<? super T> predicate)Filters a collection into a PartitionedIterable based on the evaluation of the predicate.<P> PartitionIterable<T>partitionWith(Predicate2<? super T,? super P> predicate, P parameter)Filters a collection into a PartitionIterable based on the evaluation of the predicate.RichIterable<T>reject(Predicate<? super T> predicate)Returns all elements of the source collection that return false when evaluating of the predicate.<R extends java.util.Collection<T>>
Rreject(Predicate<? super T> predicate, R target)Same as the reject method with one parameter but uses the specified target collection for the results.<P> RichIterable<T>rejectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.reject(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.<P,R extends java.util.Collection<T>>
RrejectWith(Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)Similar toRichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.RichIterable<T>select(Predicate<? super T> predicate)Returns all elements of the source collection that return true when evaluating the predicate.<R extends java.util.Collection<T>>
Rselect(Predicate<? super T> predicate, R target)Same as the select method with one parameter but uses the specified target collection for the results.<S> RichIterable<S>selectInstancesOf(java.lang.Class<S> clazz)Returns all elements of the source collection that are instances of the Classclazz.<P> RichIterable<T>selectWith(Predicate2<? super T,? super P> predicate, P parameter)Similar toRichIterable.select(Predicate), except with an evaluation parameter for the second generic argument inPredicate2.<P,R extends java.util.Collection<T>>
RselectWith(Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)Similar toRichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument inPredicate2.intsize()Returns the number of items in this iterable.<V> ObjectDoubleMap<V>sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ObjectDoubleMap<V>sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ObjectLongMap<V>sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)Groups and sums the values using the two specified functions.<V> ObjectLongMap<V>sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)Groups and sums the values using the two specified functions.doublesumOfDouble(DoubleFunction<? super T> function)Returns the final double result of evaluating function for each element of the iterable and adding the results together.doublesumOfFloat(FloatFunction<? super T> function)Returns the final double result of evaluating function for each element of the iterable and adding the results together.longsumOfInt(IntFunction<? super T> function)Returns the final long result of evaluating function for each element of the iterable and adding the results together.longsumOfLong(LongFunction<? super T> function)Returns the final long result of evaluating function for each element of the iterable and adding the results together.RichIterable<T>tap(Procedure<? super T> procedure)Executes the Procedure for each element in the iterable and returnsthis.java.lang.Object[]toArray()Converts this iterable to an array.<T> T[]toArray(T[] a)Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.MutableBag<T>toBag()Converts the collection to the default MutableBag implementation.<NK,NV>
MutableBiMap<NK,NV>toBiMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)Converts the collection to a BiMap implementation using the specified key and value functions.MutableList<T>toList()Converts the collection to a MutableList implementation.<NK,NV>
MutableMap<NK,NV>toMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)Converts the collection to a MutableMap implementation using the specified key and value functions.<NK,NV,R extends java.util.Map<NK,NV>>
RtoMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction, R target)Same asRichIterable.toMap(Function, Function), except that the results are gathered into the specifiedtargetmap.MutableSet<T>toSet()Converts the collection to a MutableSet implementation.MutableSortedBag<T>toSortedBag()Converts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.MutableSortedBag<T>toSortedBag(java.util.Comparator<? super T> comparator)Converts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.MutableList<T>toSortedList()Converts the collection to a MutableList implementation and sorts it using the natural order of the elements.MutableList<T>toSortedList(java.util.Comparator<? super T> comparator)Converts the collection to a MutableList implementation and sorts it using the specified comparator.<NK,NV>
MutableSortedMap<NK,NV>toSortedMap(java.util.Comparator<? super NK> comparator, Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the given comparator.<NK,NV>
MutableSortedMap<NK,NV>toSortedMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)Converts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the key elements' natural ordering.MutableSortedSet<T>toSortedSet()Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.MutableSortedSet<T>toSortedSet(java.util.Comparator<? super T> comparator)Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.java.lang.StringtoString()Returns a string with the elements of this iterable separated by commas with spaces and enclosed in square brackets.<S> RichIterable<Pair<T,S>>zip(java.lang.Iterable<S> that)Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.<S,R extends java.util.Collection<Pair<T,S>>>
Rzip(java.lang.Iterable<S> that, R target)Same asRichIterable.zip(Iterable)but usestargetfor output.RichIterable<Pair<T,java.lang.Integer>>zipWithIndex()Zips thisRichIterablewith its indices.<R extends java.util.Collection<Pair<T,java.lang.Integer>>>
RzipWithIndex(R target)Same asRichIterable.zipWithIndex()but usestargetfor output.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.collections.api.InternalIterable
forEach
-
Methods inherited from interface org.eclipse.collections.api.RichIterable
aggregateBy, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, countBy, countBy, countByEach, countByEach, countByWith, countByWith, flatCollectWith, flatCollectWith, forEach, getAny, groupByAndCollect, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, makeString, maxByOptional, maxOptional, maxOptional, minByOptional, minOptional, minOptional, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toSortedBagBy, toSortedListBy, toSortedMapBy, toSortedSetBy
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
iterable
protected final RichIterable<T> iterable
-
-
Constructor Detail
-
UnmodifiableRichIterable
protected UnmodifiableRichIterable(RichIterable<T> richIterable)
-
-
Method Detail
-
of
public static <E,RI extends RichIterable<E>> UnmodifiableRichIterable<E> of(RI iterable)
This method will take a RichIterable and wrap it directly in a UnmodifiableRichIterable.
-
select
public <R extends java.util.Collection<T>> R select(Predicate<? super T> predicate, R target)
Description copied from interface:RichIterableSame as the select method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> selected = people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());- Specified by:
selectin interfaceRichIterable<T>- Parameters:
predicate- aPredicateto use as the select criteriatarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
target, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate)
-
selectWith
public <P> RichIterable<T> selectWith(Predicate2<? super T,? super P> predicate, P parameter)
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 interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
selectWith
public <P,R extends java.util.Collection<T>> R selectWith(Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)
Description copied from interface:RichIterableSimilar toRichIterable.select(Predicate, Collection), 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:
MutableList<Person> selected = people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
selectWithin interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetargetCollection- the Collection to append to for all elements in thisRichIterablethat meet select criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the select criteria- See Also:
RichIterable.select(Predicate),RichIterable.select(Predicate, Collection)
-
reject
public <R extends java.util.Collection<T>> R reject(Predicate<? super T> predicate, R target)
Description copied from interface:RichIterableSame as the reject method with one parameter but uses the specified target collection for the results.Example using a Java 8 lambda expression:
MutableList<Person> rejected = people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());- Specified by:
rejectin interfaceRichIterable<T>- Parameters:
predicate- aPredicateto use as the reject criteriatarget- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
target, which contains appended elements as a result of the reject criteria
-
rejectWith
public <P> RichIterable<T> rejectWith(Predicate2<? super T,? super P> predicate, P parameter)
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 interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the select criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicate- See Also:
RichIterable.select(Predicate)
-
rejectWith
public <P,R extends java.util.Collection<T>> R rejectWith(Predicate2<? super T,? super P> predicate, P parameter, R targetCollection)
Description copied from interface:RichIterableSimilar toRichIterable.reject(Predicate, Collection), 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:
MutableList<Person> rejected = people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());- Specified by:
rejectWithin interfaceRichIterable<T>- Parameters:
predicate- aPredicate2to use as the reject criteriaparameter- a parameter to pass in for evaluation of the second argumentPinpredicatetargetCollection- the Collection to append to for all elements in thisRichIterablethat causePredicate#accept(Object)method to evaluate to false- Returns:
targetCollection, which contains appended elements as a result of the reject criteria- See Also:
RichIterable.reject(Predicate),RichIterable.reject(Predicate, Collection)
-
partition
public PartitionIterable<T> partition(Predicate<? super T> predicate)
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 interfaceRichIterable<T>
-
partitionWith
public <P> PartitionIterable<T> partitionWith(Predicate2<? super T,? 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 interfaceRichIterable<T>
-
collect
public <V,R extends java.util.Collection<V>> R collect(Function<? super T,? extends V> function, R target)
Description copied from interface:RichIterableSame asRichIterable.collect(Function), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
MutableList<String> names = people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());- Specified by:
collectin interfaceRichIterable<T>- Parameters:
function- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
target, which contains appended elements as a result of the collect transformation- See Also:
RichIterable.collect(Function)
-
collectWith
public <P,V> RichIterable<V> collectWith(Function2<? super T,? super P,? extends V> 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 interfaceRichIterable<T>- 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:
RichIterable.collect(Function)
-
collectWith
public <P,V,R extends java.util.Collection<V>> R collectWith(Function2<? super T,? super P,? extends V> function, P parameter, R targetCollection)
Description copied from interface:RichIterableSame as collectWith but with a targetCollection parameter to gather the results.Example using a Java 8 lambda expression:
MutableSet<Integer> integers = Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());- Specified by:
collectWithin interfaceRichIterable<T>- Parameters:
function- aFunction2to use as the collect transformation functionparameter- a parameter to pass in for evaluation of the second argumentPinfunctiontargetCollection- the Collection to append to for all elements in thisRichIterablethat meet select criteriafunction- Returns:
targetCollection, which contains appended elements as a result of the collect transformation
-
collectIf
public <V,R extends java.util.Collection<V>> R collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> function, R target)
Description copied from interface:RichIterableSame as the collectIf method with two parameters but uses the specified target collection for the results.- Specified by:
collectIfin interfaceRichIterable<T>- Parameters:
predicate- aPredicateto use as the select criteriafunction- aFunctionto use as the collect transformation functiontarget- the Collection to append to for all elements in thisRichIterablethat meet the collect criteriapredicate- Returns:
targetCollection, which contains appended elements as a result of the collect criteria and transformation- See Also:
RichIterable.collectIf(Predicate, Function)
-
flatCollect
public <V,R extends java.util.Collection<V>> R flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
contains
public boolean contains(java.lang.Object object)
Description copied from interface:RichIterableReturns true if the iterable has an element which responds true to element.equals(object).- Specified by:
containsin interfaceRichIterable<T>
-
containsAllIterable
public boolean containsAllIterable(java.lang.Iterable<?> source)
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllIterablein interfaceRichIterable<T>
-
containsAll
public boolean containsAll(java.util.Collection<?> source)
Description copied from interface:RichIterableReturns true if all elements in source are contained in this collection.- Specified by:
containsAllin interfaceRichIterable<T>- See Also:
Collection.containsAll(Collection)
-
containsAllArguments
public boolean containsAllArguments(java.lang.Object... elements)
Description copied from interface:RichIterableReturns true if all elements in the specified var arg array are contained in this collection.- Specified by:
containsAllArgumentsin interfaceRichIterable<T>
-
toArray
public java.lang.Object[] toArray()
Description copied from interface:RichIterableConverts this iterable to an array.- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
Collection.toArray()
-
toArray
public <T> T[] toArray(T[] a)
Description copied from interface:RichIterableConverts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.- Specified by:
toArrayin interfaceRichIterable<T>- See Also:
Collection.toArray(Object[])
-
tap
public RichIterable<T> tap(Procedure<? super T> procedure)
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 interfaceRichIterable<T>- See Also:
RichIterable.each(Procedure),RichIterable.forEach(Procedure)
-
each
public void each(Procedure<? super T> procedure)
Description copied from interface:RichIterableThe procedure is executed for each element in the iterable.Example using a Java 8 lambda expression:
people.each(person -> LOGGER.info(person.getName()));
This method is a variant ofInternalIterable.forEach(Procedure)that has a signature conflict withIterable.forEach(java.util.function.Consumer).- Specified by:
eachin interfaceRichIterable<T>- See Also:
InternalIterable.forEach(Procedure),Iterable.forEach(java.util.function.Consumer)
-
forEachWithIndex
public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
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<T>
-
forEachWith
public <P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
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<T>
-
notEmpty
public boolean notEmpty()
Description copied from interface:RichIterableThe English equivalent of !this.isEmpty()- Specified by:
notEmptyin interfaceRichIterable<T>
-
isEmpty
public boolean isEmpty()
Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceRichIterable<T>
-
size
public int size()
Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceRichIterable<T>
-
getFirst
public T getFirst()
Description copied from interface:RichIterableReturns the first element of an iterable. In the case of a List it is the element at the first index. In the case of any other Collection, it is the first element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the first element could be any element from the Set.
- Specified by:
getFirstin interfaceRichIterable<T>
-
getLast
public T getLast()
Description copied from interface:RichIterableReturns the last element of an iterable. In the case of a List it is the element at the last index. In the case of any other Collection, it is the last element that would be returned during an iteration. If the iterable is empty, null is returned. If null is a valid element of the container, then a developer would need to check to see if the iterable is empty to validate that a null result was not due to the container being empty.The order of Sets are not guaranteed (except for TreeSets and other Ordered Set implementations), so if you use this method, the last element could be any element from the Set.
- Specified by:
getLastin interfaceRichIterable<T>
-
getOnly
public T getOnly()
Description copied from interface:RichIterableReturns the element if the iterable has exactly one element. Otherwise, throwIllegalStateException.- Specified by:
getOnlyin interfaceRichIterable<T>- Returns:
- an element of an iterable.
-
select
public RichIterable<T> select(Predicate<? super T> predicate)
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 interfaceRichIterable<T>
-
reject
public RichIterable<T> reject(Predicate<? super T> predicate)
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 interfaceRichIterable<T>- Parameters:
predicate- aPredicateto use as the reject criteria- Returns:
- a RichIterable that contains elements that cause
Predicate.accept(Object)method to evaluate to false
-
selectInstancesOf
public <S> RichIterable<S> selectInstancesOf(java.lang.Class<S> clazz)
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 interfaceRichIterable<T>
-
collect
public <V> RichIterable<V> collect(Function<? super T,? extends V> function)
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 interfaceRichIterable<T>
-
collectBoolean
public BooleanIterable collectBoolean(BooleanFunction<? super T> booleanFunction)
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 interfaceRichIterable<T>
-
collectBoolean
public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super T> booleanFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
BooleanArrayList licenses = people.collectBoolean(person -> person.hasDrivingLicense(), new BooleanArrayList());- Specified by:
collectBooleanin interfaceRichIterable<T>- Parameters:
booleanFunction- aBooleanFunctionto use as the collect transformation functiontarget- the MutableBooleanCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectBoolean
public <R extends MutableBooleanCollection> R flatCollectBoolean(Function<? super T,? extends BooleanIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBooleanin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectByte
public ByteIterable collectByte(ByteFunction<? super T> byteFunction)
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 interfaceRichIterable<T>
-
collectByte
public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectByte(ByteFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ByteArrayList bytes = people.collectByte(person -> person.getCode(), new ByteArrayList());- Specified by:
collectBytein interfaceRichIterable<T>- Parameters:
byteFunction- aByteFunctionto use as the collect transformation functiontarget- the MutableByteCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectByte
public <R extends MutableByteCollection> R flatCollectByte(Function<? super T,? extends ByteIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectBytein interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectChar
public CharIterable collectChar(CharFunction<? super T> charFunction)
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 interfaceRichIterable<T>
-
collectChar
public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectChar(CharFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
CharArrayList chars = people.collectChar(person -> person.getMiddleInitial(), new CharArrayList());- Specified by:
collectCharin interfaceRichIterable<T>- Parameters:
charFunction- aCharFunctionto use as the collect transformation functiontarget- the MutableCharCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectChar
public <R extends MutableCharCollection> R flatCollectChar(Function<? super T,? extends CharIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectCharin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectDouble
public DoubleIterable collectDouble(DoubleFunction<? super T> doubleFunction)
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 interfaceRichIterable<T>
-
collectDouble
public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super T> doubleFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
DoubleArrayList doubles = people.collectDouble(person -> person.getMilesFromNorthPole(), new DoubleArrayList());- Specified by:
collectDoublein interfaceRichIterable<T>- Parameters:
doubleFunction- aDoubleFunctionto use as the collect transformation functiontarget- the MutableDoubleCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectDouble
public <R extends MutableDoubleCollection> R flatCollectDouble(Function<? super T,? extends DoubleIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectDoublein interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectFloat
public FloatIterable collectFloat(FloatFunction<? super T> floatFunction)
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 interfaceRichIterable<T>
-
collectFloat
public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectFloat(FloatFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
FloatArrayList floats = people.collectFloat(person -> person.getHeightInInches(), new FloatArrayList());- Specified by:
collectFloatin interfaceRichIterable<T>- Parameters:
floatFunction- aFloatFunctionto use as the collect transformation functiontarget- the MutableFloatCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectFloat
public <R extends MutableFloatCollection> R flatCollectFloat(Function<? super T,? extends FloatIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectFloatin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectInt
public IntIterable collectInt(IntFunction<? super T> intFunction)
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 interfaceRichIterable<T>
-
collectInt
public <R extends MutableIntCollection> R collectInt(IntFunction<? super T> intFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectInt(IntFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
IntArrayList ints = people.collectInt(person -> person.getAge(), new IntArrayList());- Specified by:
collectIntin interfaceRichIterable<T>- Parameters:
intFunction- aIntFunctionto use as the collect transformation functiontarget- the MutableIntCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectInt
public <R extends MutableIntCollection> R flatCollectInt(Function<? super T,? extends IntIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectIntin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectLong
public LongIterable collectLong(LongFunction<? super T> longFunction)
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 interfaceRichIterable<T>
-
collectLong
public <R extends MutableLongCollection> R collectLong(LongFunction<? super T> longFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectLong(LongFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
LongArrayList longs = people.collectLong(person -> person.getGuid(), new LongArrayList());- Specified by:
collectLongin interfaceRichIterable<T>- Parameters:
longFunction- aLongFunctionto use as the collect transformation functiontarget- the MutableLongCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectLong
public <R extends MutableLongCollection> R flatCollectLong(Function<? super T,? extends LongIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectLongin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
collectShort
public ShortIterable collectShort(ShortFunction<? super T> shortFunction)
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 interfaceRichIterable<T>
-
collectShort
public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.collectShort(ShortFunction), except that the results are gathered into the specifiedtargetcollection.Example using a Java 8 lambda expression:
ShortArrayList shorts = people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth, new ShortArrayList());- Specified by:
collectShortin interfaceRichIterable<T>- Parameters:
shortFunction- aShortFunctionto use as the collect transformation functiontarget- the MutableShortCollection to append to for all elements in thisRichIterable- Returns:
target, which contains appended elements as a result of the collect transformation
-
flatCollectShort
public <R extends MutableShortCollection> R flatCollectShort(Function<? super T,? extends ShortIterable> function, R target)
Description copied from interface:RichIterableSame as flatCollect, only the results are collected into the target collection.- Specified by:
flatCollectShortin interfaceRichIterable<T>- Parameters:
function- TheFunctionto applytarget- The collection into which results should be added.- Returns:
target, which will contain a flattened collection of results produced by applying the givenfunction- See Also:
RichIterable.flatCollect(Function)
-
flatCollect
public <V> RichIterable<V> flatCollect(Function<? super T,? extends java.lang.Iterable<V>> function)
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 interfaceRichIterable<T>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
collectIf
public <V> RichIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T,? extends V> 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 interfaceRichIterable<T>
-
detect
public T detect(Predicate<? super T> predicate)
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<T>
-
detectWith
public <P> T detectWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter, or null if none evaluate to true.Example using a Java 8 lambda expression:
Person person = people.detectWith((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithin interfaceRichIterable<T>
-
detectOptional
public java.util.Optional<T> detectOptional(Predicate<? super T> predicate)
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<T>
-
detectWithOptional
public <P> java.util.Optional<T> detectWithOptional(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns the first element that evaluates to true for the specified predicate2 and parameter as an Optional.Example using a Java 8 lambda expression:
Optional<Person> person = people.detectWithOptional((person, fullName) -> person.getFullName().equals(fullName), "John Smith");- Specified by:
detectWithOptionalin interfaceRichIterable<T>
-
detectIfNone
public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function)
Description copied from interface:RichIterableReturns the first element of the iterable for which the predicate evaluates to true. If no element matches the predicate, then returns the value of applying the specified function.- Specified by:
detectIfNonein interfaceRichIterable<T>
-
detectWithIfNone
public <P> T detectWithIfNone(Predicate2<? super T,? super P> predicate, P parameter, Function0<? extends T> function)
Description copied from interface:RichIterableReturns the first element of the iterable that evaluates to true for the specified predicate2 and parameter, or returns the value of evaluating the specified function.- Specified by:
detectWithIfNonein interfaceRichIterable<T>
-
min
public T min(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator.- Specified by:
minin interfaceRichIterable<T>
-
max
public T max(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator.- Specified by:
maxin interfaceRichIterable<T>
-
min
public T min()
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order.- Specified by:
minin interfaceRichIterable<T>
-
max
public T max()
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order.- Specified by:
maxin interfaceRichIterable<T>
-
minBy
public <V extends java.lang.Comparable<? super V>> T minBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns the minimum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
minByin interfaceRichIterable<T>
-
maxBy
public <V extends java.lang.Comparable<? super V>> T maxBy(Function<? super T,? extends V> function)
Description copied from interface:RichIterableReturns the maximum elements out of this container based on the natural order of the attribute returned by Function.- Specified by:
maxByin interfaceRichIterable<T>
-
count
public int count(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturn the total number of elements that answer true to the specified predicate.Example using a Java 8 lambda expression:
int count = people.count(person -> person.getAddress().getState().getName().equals("New York"));- Specified by:
countin interfaceRichIterable<T>
-
countWith
public <P> int countWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns the total number of elements that evaluate to true for the specified predicate.e.g. return lastNames.countWith(Predicates2.equal(), "Smith");
- Specified by:
countWithin interfaceRichIterable<T>
-
anySatisfy
public boolean anySatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the iterable. Returns false if the iterable is empty, or if no element returned true when evaluating the predicate.- Specified by:
anySatisfyin interfaceRichIterable<T>
-
anySatisfyWith
public <P> boolean anySatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for any element of the collection, or return false. Returns false if the collection is empty.- Specified by:
anySatisfyWithin interfaceRichIterable<T>
-
allSatisfy
public boolean allSatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
allSatisfyin interfaceRichIterable<T>
-
allSatisfyWith
public <P> boolean allSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns true if the predicate evaluates to true for every element of the collection, or returns false.- Specified by:
allSatisfyWithin interfaceRichIterable<T>
-
noneSatisfy
public boolean noneSatisfy(Predicate<? super T> predicate)
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.- Specified by:
noneSatisfyin interfaceRichIterable<T>
-
noneSatisfyWith
public <P> boolean noneSatisfyWith(Predicate2<? super T,? super P> predicate, P parameter)
Description copied from interface:RichIterableReturns true if the predicate evaluates to false for every element of the collection, or return false. Returns true if the collection is empty.- Specified by:
noneSatisfyWithin interfaceRichIterable<T>
-
injectInto
public <IV> IV injectInto(IV injectedValue, Function2<? super IV,? super T,? extends IV> function)Description copied from interface:RichIterableReturns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
public int injectInto(int injectedValue, IntObjectToIntFunction<? super T> function)Description copied from interface:RichIterableReturns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
public long injectInto(long injectedValue, LongObjectToLongFunction<? super T> function)Description copied from interface:RichIterableReturns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function)Description copied from interface:RichIterableReturns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>
-
injectInto
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function)Description copied from interface:RichIterableReturns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.- Specified by:
injectIntoin interfaceRichIterable<T>
-
sumOfInt
public long sumOfInt(IntFunction<? super T> function)
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfIntin interfaceRichIterable<T>
-
sumOfFloat
public double sumOfFloat(FloatFunction<? super T> function)
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfFloatin interfaceRichIterable<T>
-
sumOfLong
public long sumOfLong(LongFunction<? super T> function)
Description copied from interface:RichIterableReturns the final long result of evaluating function for each element of the iterable and adding the results together.- Specified by:
sumOfLongin interfaceRichIterable<T>
-
sumOfDouble
public double sumOfDouble(DoubleFunction<? super T> function)
Description copied from interface:RichIterableReturns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.- Specified by:
sumOfDoublein interfaceRichIterable<T>
-
sumByInt
public <V> ObjectLongMap<V> sumByInt(Function<? super T,? extends V> groupBy, IntFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByIntin interfaceRichIterable<T>
-
sumByFloat
public <V> ObjectDoubleMap<V> sumByFloat(Function<? super T,? extends V> groupBy, FloatFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByFloatin interfaceRichIterable<T>
-
sumByLong
public <V> ObjectLongMap<V> sumByLong(Function<? super T,? extends V> groupBy, LongFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByLongin interfaceRichIterable<T>
-
sumByDouble
public <V> ObjectDoubleMap<V> sumByDouble(Function<? super T,? extends V> groupBy, DoubleFunction<? super T> function)
Description copied from interface:RichIterableGroups and sums the values using the two specified functions.- Specified by:
sumByDoublein interfaceRichIterable<T>
-
into
public <R extends java.util.Collection<T>> R into(R target)
Description copied from interface:RichIterableAdds all the elements in this iterable to the specific target Collection.- Specified by:
intoin interfaceRichIterable<T>
-
toList
public MutableList<T> toList()
Description copied from interface:RichIterableConverts the collection to a MutableList implementation.- Specified by:
toListin interfaceRichIterable<T>
-
toSortedList
public MutableList<T> toSortedList()
Description copied from interface:RichIterableConverts the collection to a MutableList implementation and sorts it using the natural order of the elements.- Specified by:
toSortedListin interfaceRichIterable<T>
-
toSortedList
public MutableList<T> toSortedList(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableConverts the collection to a MutableList implementation and sorts it using the specified comparator.- Specified by:
toSortedListin interfaceRichIterable<T>
-
toSortedSet
public MutableSortedSet<T> toSortedSet()
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.- Specified by:
toSortedSetin interfaceRichIterable<T>
-
toSortedSet
public MutableSortedSet<T> toSortedSet(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableConverts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.- Specified by:
toSortedSetin interfaceRichIterable<T>
-
toSet
public MutableSet<T> toSet()
Description copied from interface:RichIterableConverts the collection to a MutableSet implementation.- Specified by:
toSetin interfaceRichIterable<T>
-
toBag
public MutableBag<T> toBag()
Description copied from interface:RichIterableConverts the collection to the default MutableBag implementation.- Specified by:
toBagin interfaceRichIterable<T>
-
toSortedBag
public MutableSortedBag<T> toSortedBag()
Description copied from interface:RichIterableConverts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.- Specified by:
toSortedBagin interfaceRichIterable<T>
-
toSortedBag
public MutableSortedBag<T> toSortedBag(java.util.Comparator<? super T> comparator)
Description copied from interface:RichIterableConverts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.- Specified by:
toSortedBagin interfaceRichIterable<T>
-
toMap
public <NK,NV> MutableMap<NK,NV> toMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)
Description copied from interface:RichIterableConverts the collection to a MutableMap implementation using the specified key and value functions.- Specified by:
toMapin interfaceRichIterable<T>
-
toMap
public <NK,NV,R extends java.util.Map<NK,NV>> R toMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction, R target)
Description copied from interface:RichIterableSame asRichIterable.toMap(Function, Function), except that the results are gathered into the specifiedtargetmap.- Specified by:
toMapin interfaceRichIterable<T>
-
toSortedMap
public <NK,NV> MutableSortedMap<NK,NV> toSortedMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)
Description copied from interface:RichIterableConverts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the key elements' natural ordering.- Specified by:
toSortedMapin interfaceRichIterable<T>
-
toSortedMap
public <NK,NV> MutableSortedMap<NK,NV> toSortedMap(java.util.Comparator<? super NK> comparator, Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)
Description copied from interface:RichIterableConverts the collection to a MutableSortedMap implementation using the specified key and value functions sorted by the given comparator.- Specified by:
toSortedMapin interfaceRichIterable<T>
-
toBiMap
public <NK,NV> MutableBiMap<NK,NV> toBiMap(Function<? super T,? extends NK> keyFunction, Function<? super T,? extends NV> valueFunction)
Description copied from interface:RichIterableConverts the collection to a BiMap implementation using the specified key and value functions.- Specified by:
toBiMapin interfaceRichIterable<T>
-
asLazy
public LazyIterable<T> asLazy()
Description copied from interface:RichIterableReturns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).- Specified by:
asLazyin interfaceRichIterable<T>
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T>
-
toString
public java.lang.String toString()
Description copied from interface:RichIterableReturns a string with the elements of this 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 interfaceRichIterable<T>- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this RichIterable
- See Also:
AbstractCollection.toString()
-
makeString
public java.lang.String makeString()
Description copied from interface:RichIterableReturns a string representation of this collection by delegating toRichIterable.makeString(String)and defaulting the separator parameter to the characters", "(comma and space).- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
makeString
public java.lang.String makeString(java.lang.String separator)
Description copied from interface:RichIterableReturns a string representation of this collection by delegating toRichIterable.makeString(String, String, String)and defaulting the start and end parameters to""(the empty String).- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
makeString
public java.lang.String makeString(java.lang.String start, java.lang.String separator, java.lang.String end)Description copied from interface:RichIterableReturns a string representation of this collection with the elements separated by the specified separator and enclosed between the start and end strings.- Specified by:
makeStringin interfaceRichIterable<T>- Returns:
- a string representation of this collection.
-
appendString
public void appendString(java.lang.Appendable appendable)
Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString().- Specified by:
appendStringin interfaceRichIterable<T>
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String separator)Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString(String).- Specified by:
appendStringin interfaceRichIterable<T>
-
appendString
public void appendString(java.lang.Appendable appendable, java.lang.String start, java.lang.String separator, java.lang.String end)Description copied from interface:RichIterablePrints a string representation of this collection onto the givenAppendable. Prints the string returned byRichIterable.makeString(String, String, String).- Specified by:
appendStringin interfaceRichIterable<T>
-
groupBy
public <V> Multimap<V,T> groupBy(Function<? super T,? extends V> function)
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 interfaceRichIterable<T>
-
groupBy
public <V,R extends MutableMultimap<V,T>> R groupBy(Function<? super T,? extends V> function, R target)
Description copied from interface:RichIterableSame asRichIterable.groupBy(Function), except that the results are gathered into the specifiedtargetmultimap.Example using a Java 8 method reference:
FastListMultimap<String, Person> peopleByLastName = people.groupBy(Person::getLastName, new FastListMultimap<String, Person>());- Specified by:
groupByin interfaceRichIterable<T>
-
groupByEach
public <V> Multimap<V,T> groupByEach(Function<? super T,? extends java.lang.Iterable<V>> 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 interfaceRichIterable<T>
-
groupByEach
public <V,R extends MutableMultimap<V,T>> R groupByEach(Function<? super T,? extends java.lang.Iterable<V>> function, R target)
Description copied from interface:RichIterableSame asRichIterable.groupByEach(Function), except that the results are gathered into the specifiedtargetmultimap.- Specified by:
groupByEachin interfaceRichIterable<T>
-
groupByUniqueKey
public <V> MapIterable<V,T> groupByUniqueKey(Function<? super T,? extends V> function)
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 interfaceRichIterable<T>- See Also:
RichIterable.groupBy(Function)
-
groupByUniqueKey
public <V,R extends MutableMapIterable<V,T>> R groupByUniqueKey(Function<? super T,? extends V> function, R target)
Description copied from interface:RichIterableSame asRichIterable.groupByUniqueKey(Function), except that the results are gathered into the specifiedtargetmap.- Specified by:
groupByUniqueKeyin interfaceRichIterable<T>- See Also:
RichIterable.groupByUniqueKey(Function)
-
zip
public <S> RichIterable<Pair<T,S>> zip(java.lang.Iterable<S> that)
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 interfaceRichIterable<T>- 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.
-
zip
public <S,R extends java.util.Collection<Pair<T,S>>> R zip(java.lang.Iterable<S> that, R target)
Description copied from interface:RichIterableSame asRichIterable.zip(Iterable)but usestargetfor output.- Specified by:
zipin interfaceRichIterable<T>
-
zipWithIndex
public RichIterable<Pair<T,java.lang.Integer>> zipWithIndex()
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceRichIterable<T>- Returns:
- A new
RichIterablecontaining pairs consisting of all elements of thisRichIterablepaired with their index. Indices start at 0. - See Also:
RichIterable.zip(Iterable)
-
zipWithIndex
public <R extends java.util.Collection<Pair<T,java.lang.Integer>>> R zipWithIndex(R target)
Description copied from interface:RichIterableSame asRichIterable.zipWithIndex()but usestargetfor output.- Specified by:
zipWithIndexin interfaceRichIterable<T>
-
chunk
public RichIterable<RichIterable<T>> chunk(int size)
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceRichIterable<T>- Parameters:
size- the number of elements per chunk- Returns:
- A
RichIterablecontainingRichIterables of sizesize, except the last will be truncated if the elements don't divide evenly.
-
aggregateInPlaceBy
public <K,V> MapIterable<K,V> aggregateInPlaceBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V,? super T> 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 interfaceRichIterable<T>
-
aggregateBy
public <K,V> MapIterable<K,V> aggregateBy(Function<? super T,? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V,? super T,? extends V> 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 interfaceRichIterable<T>
-
-