Class AbstractLazyIterable<T>
- All Implemented Interfaces:
Iterable<T>, InternalIterable<T>, LazyIterable<T>, RichIterable<T>
- Direct Known Subclasses:
ByteBooleanHashMap.KeyValuesView, ByteByteHashMap.KeyValuesView, ByteCharHashMap.KeyValuesView, ByteDoubleHashMap.KeyValuesView, ByteFloatHashMap.KeyValuesView, ByteIntHashMap.KeyValuesView, ByteLongHashMap.KeyValuesView, ByteObjectHashMap.KeyValuesView, ByteShortHashMap.KeyValuesView, CharBooleanHashMap.KeyValuesView, CharByteHashMap.KeyValuesView, CharCharHashMap.KeyValuesView, CharDoubleHashMap.KeyValuesView, CharFloatHashMap.KeyValuesView, CharIntHashMap.KeyValuesView, CharLongHashMap.KeyValuesView, CharObjectHashMap.KeyValuesView, CharShortHashMap.KeyValuesView, ChunkBooleanIterable, ChunkByteIterable, ChunkCharIterable, ChunkDoubleIterable, ChunkFloatIterable, ChunkIntIterable, ChunkIterable, ChunkLongIterable, ChunkShortIterable, CollectBooleanToObjectIterable, CollectByteToObjectIterable, CollectCharToObjectIterable, CollectDoubleToObjectIterable, CollectFloatToObjectIterable, CollectIntToObjectIterable, CollectIterable, CollectLongToObjectIterable, CollectShortToObjectIterable, CompositeIterable, DistinctIterable, DoubleBooleanHashMap.KeyValuesView, DoubleByteHashMap.KeyValuesView, DoubleCharHashMap.KeyValuesView, DoubleDoubleHashMap.KeyValuesView, DoubleFloatHashMap.KeyValuesView, DoubleIntHashMap.KeyValuesView, DoubleLongHashMap.KeyValuesView, DoubleObjectHashMap.KeyValuesView, DoubleShortHashMap.KeyValuesView, DropIterable, DropWhileIterable, FlatCollectBooleanToObjectIterable, FlatCollectByteToObjectIterable, FlatCollectCharToObjectIterable, FlatCollectDoubleToObjectIterable, FlatCollectFloatToObjectIterable, FlatCollectIntToObjectIterable, FlatCollectIterable, FlatCollectLongToObjectIterable, FlatCollectShortToObjectIterable, FloatBooleanHashMap.KeyValuesView, FloatByteHashMap.KeyValuesView, FloatCharHashMap.KeyValuesView, FloatDoubleHashMap.KeyValuesView, FloatFloatHashMap.KeyValuesView, FloatIntHashMap.KeyValuesView, FloatLongHashMap.KeyValuesView, FloatObjectHashMap.KeyValuesView, FloatShortHashMap.KeyValuesView, ImmutableTreeSet.SortedSetIterableParallelIterable.SortedSetIterableParallelBatchLazyIterable, IntBooleanHashMap.KeyValuesView, IntByteHashMap.KeyValuesView, IntCharHashMap.KeyValuesView, IntDoubleHashMap.KeyValuesView, Interval, IntFloatHashMap.KeyValuesView, IntIntHashMap.KeyValuesView, IntLongHashMap.KeyValuesView, IntObjectHashMap.KeyValuesView, IntShortHashMap.KeyValuesView, LazyIterableAdapter, ListIterableParallelIterable.ListIterableParallelBatchLazyIterable, LongBooleanHashMap.KeyValuesView, LongByteHashMap.KeyValuesView, LongCharHashMap.KeyValuesView, LongDoubleHashMap.KeyValuesView, LongFloatHashMap.KeyValuesView, LongIntHashMap.KeyValuesView, LongLongHashMap.KeyValuesView, LongObjectHashMap.KeyValuesView, LongShortHashMap.KeyValuesView, ObjectBooleanHashMap.KeysView, ObjectBooleanHashMap.KeyValuesView, ObjectBooleanHashMapWithHashingStrategy.KeysView, ObjectBooleanHashMapWithHashingStrategy.KeyValuesView, ObjectByteHashMap.KeysView, ObjectByteHashMap.KeyValuesView, ObjectByteHashMapWithHashingStrategy.KeysView, ObjectByteHashMapWithHashingStrategy.KeyValuesView, ObjectCharHashMap.KeysView, ObjectCharHashMap.KeyValuesView, ObjectCharHashMapWithHashingStrategy.KeysView, ObjectCharHashMapWithHashingStrategy.KeyValuesView, ObjectDoubleHashMap.KeysView, ObjectDoubleHashMap.KeyValuesView, ObjectDoubleHashMapWithHashingStrategy.KeysView, ObjectDoubleHashMapWithHashingStrategy.KeyValuesView, ObjectFloatHashMap.KeysView, ObjectFloatHashMap.KeyValuesView, ObjectFloatHashMapWithHashingStrategy.KeysView, ObjectFloatHashMapWithHashingStrategy.KeyValuesView, ObjectIntHashMap.KeysView, ObjectIntHashMap.KeyValuesView, ObjectIntHashMapWithHashingStrategy.KeysView, ObjectIntHashMapWithHashingStrategy.KeyValuesView, ObjectLongHashMap.KeysView, ObjectLongHashMap.KeyValuesView, ObjectLongHashMapWithHashingStrategy.KeysView, ObjectLongHashMapWithHashingStrategy.KeyValuesView, ObjectShortHashMap.KeysView, ObjectShortHashMap.KeyValuesView, ObjectShortHashMapWithHashingStrategy.KeysView, ObjectShortHashMapWithHashingStrategy.KeyValuesView, RejectIterable, ReverseIterable, SelectInstancesOfIterable, SelectIterable, ShortBooleanHashMap.KeyValuesView, ShortByteHashMap.KeyValuesView, ShortCharHashMap.KeyValuesView, ShortDoubleHashMap.KeyValuesView, ShortFloatHashMap.KeyValuesView, ShortIntHashMap.KeyValuesView, ShortLongHashMap.KeyValuesView, ShortObjectHashMap.KeyValuesView, ShortShortHashMap.KeyValuesView, TakeIterable, TakeWhileIterable, TapIterable, UnifiedSet.UnifiedSetParallelUnsortedIterable.UnifiedSetParallelSplitLazyIterable, UnifiedSetWithHashingStrategy.UnifiedSetParallelUnsortedIterable.UnifiedSetParallelSplitLazyIterable, ZipIterable, ZipWithIndexIterable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionasLazy()Returns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).chunk(int size) Partitions elements in fixed size chunks.<V> LazyIterable<V> Returns a new collection with the results of applying the specified function on each element of the source collection.collectBoolean(BooleanFunction<? super T> booleanFunction) Returns a new primitivebooleaniterable with the results of applying the specified function on each element of the source collection.collectByte(ByteFunction<? super T> byteFunction) Returns a new primitivebyteiterable with the results of applying the specified function on each element of the source collection.collectChar(CharFunction<? super T> charFunction) Returns a new primitivechariterable with the results of applying the specified function on each element of the source collection.collectDouble(DoubleFunction<? super T> doubleFunction) Returns a new primitivedoubleiterable with the results of applying the specified function on each element of the source collection.collectFloat(FloatFunction<? super T> floatFunction) Returns a new primitivefloatiterable with the results of applying the specified function on each element of the source collection.<V> LazyIterable<V> 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 T> intFunction) Returns a new primitiveintiterable with the results of applying the specified function on each element of the source collection.collectLong(LongFunction<? super T> longFunction) Returns a new primitivelongiterable with the results of applying the specified function on each element of the source collection.collectShort(ShortFunction<? super T> shortFunction) Returns a new primitiveshortiterable with the results of applying the specified function on each element of the source collection.<P,V> LazyIterable <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.concatenate(Iterable<T> iterable) Creates a deferred iterable that will join this iterable with the specified iterable.distinct()Creates a deferred distinct iterable to get distinct elements from the current iterable.drop(int count) Creates a deferred drop iterable for the current iterable using the specified count as the limit.<V> LazyIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function) flatCollectis a special case ofRichIterable.collect(Function).getFirst()Returns the first element of an iterable.getLast()Returns the last element of an iterable.getOnly()Returns the element if the iterable has exactly one element.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.groupByEach(Function<? super T, ? extends Iterable<V>> function) Similar toRichIterable.groupBy(Function), except the result of evaluating function will return a collection of keys for each value.<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.<R extends 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.<V extends Comparable<? super V>>
Optional<T> maxByOptional(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 as an Optional.Returns the maximum element out of this container based on the natural order as an Optional.maxOptional(Comparator<? super T> comparator) Returns the maximum element out of this container based on the comparator as an Optional.<V extends Comparable<? super V>>
Optional<T> minByOptional(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 as an Optional.Returns the minimum element out of this container based on the natural order as an Optional.minOptional(Comparator<? super T> comparator) Returns the minimum element out of this container based on the comparator as an Optional.Filters a collection into a PartitionedIterable based on the evaluation of the predicate.<P> PartitionMutableList<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter) Filters a collection into a PartitionIterable based on the evaluation of the predicate.Returns all elements of the source collection that return false when evaluating of the predicate.<P> LazyIterable<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.Returns all elements of the source collection that return true when evaluating the predicate.<S> LazyIterable<S> selectInstancesOf(Class<S> clazz) Returns all elements of the source collection that are instances of the Classclazz.<P> LazyIterable<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.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.take(int count) Creates a deferred take iterable for the current iterable using the specified count as the limit.Executes the Procedure for each element in the iterable and returnsthis.toStack()<S> LazyIterable<Pair<T, S>> Returns aRichIterableformed from thisRichIterableand anotherRichIterableby combining corresponding elements in pairs.Zips thisRichIterablewith its indices.Methods inherited from class AbstractRichIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, collect, collectIf, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countByEach, countWith, detect, detectOptional, detectWith, detectWithIfNone, detectWithOptional, flatCollect, forEach, forEachWith, forEachWithIndex, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, toString, zip, zipWithIndexMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface Iterable
iterator, spliteratorMethods inherited from interface LazyIterable
flatCollectWith, toArray, toArray, toImmutableBag, toImmutableList, toImmutableSetMethods inherited from interface RichIterable
aggregateBy, aggregateBy, aggregateInPlaceBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countBy, countByEach, countByEach, countByWith, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, makeString, makeString, makeString, makeString, max, max, maxBy, min, min, minBy, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toImmutableBiMap, toImmutableMap, 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, toString, zip, zipWithIndex
-
Constructor Details
-
AbstractLazyIterable
public AbstractLazyIterable()
-
-
Method Details
-
asLazy
Description copied from interface:RichIterableReturns a lazy (deferred) iterable, most likely implemented by calling LazyIterate.adapt(this).- Specified by:
asLazyin interfaceRichIterable<T>- Overrides:
asLazyin classAbstractRichIterable<T>
-
into
Description copied from interface:RichIterableAdds all the elements in this iterable to the specific target Collection.- Specified by:
intoin interfaceLazyIterable<T>- Specified by:
intoin interfaceRichIterable<T>- Overrides:
intoin classAbstractRichIterable<T>
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable.- Specified by:
sizein interfaceRichIterable<T>
-
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceRichIterable<T>- Overrides:
isEmptyin classAbstractRichIterable<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 interfaceLazyIterable<T>- Specified by:
getFirstin interfaceRichIterable<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
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
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 interfaceLazyIterable<T>- Specified by:
selectin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- 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:
-
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 interfaceLazyIterable<T>- 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
-
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 interfaceLazyIterable<T>- 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:
-
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 interfaceRichIterable<T>
-
partitionWith
public <P> PartitionMutableList<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>
-
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 interfaceLazyIterable<T>- Specified by:
selectInstancesOfin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectBooleanin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectBytein interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectCharin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectDoublein interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectFloatin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectIntin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectLongin interfaceRichIterable<T>
-
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 interfaceLazyIterable<T>- Specified by:
collectShortin interfaceRichIterable<T>
-
collectWith
public <P,V> LazyIterable<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 interfaceLazyIterable<T>- 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:
-
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 interfaceLazyIterable<T>- Specified by:
flatCollectin interfaceRichIterable<T>- Parameters:
function- TheFunctionto apply- Returns:
- a new flattened collection produced by applying the given
function
-
concatenate
Description copied from interface:LazyIterableCreates a deferred iterable that will join this iterable with the specified iterable.- Specified by:
concatenatein interfaceLazyIterable<T>
-
collectIf
public <V> LazyIterable<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 interfaceLazyIterable<T>- Specified by:
collectIfin interfaceRichIterable<T>
-
take
Description copied from interface:LazyIterableCreates a deferred take iterable for the current iterable using the specified count as the limit.- Specified by:
takein interfaceLazyIterable<T>
-
drop
Description copied from interface:LazyIterableCreates a deferred drop iterable for the current iterable using the specified count as the limit.- Specified by:
dropin interfaceLazyIterable<T>
-
takeWhile
- Specified by:
takeWhilein interfaceLazyIterable<T>- See Also:
-
dropWhile
- Specified by:
dropWhilein interfaceLazyIterable<T>- See Also:
-
distinct
Description copied from interface:LazyIterableCreates a deferred distinct iterable to get distinct elements from the current iterable.- Specified by:
distinctin interfaceLazyIterable<T>
-
toStack
-
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 interfaceRichIterable<T>
-
groupByEach
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>
-
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 interfaceRichIterable<T>- 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 interfaceLazyIterable<T>- 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.
-
zipWithIndex
Description copied from interface:RichIterableZips thisRichIterablewith its indices.- Specified by:
zipWithIndexin interfaceLazyIterable<T>- 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:
-
chunk
Description copied from interface:RichIterablePartitions elements in fixed size chunks.- Specified by:
chunkin interfaceLazyIterable<T>- 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.
-
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 interfaceLazyIterable<T>- Specified by:
tapin interfaceRichIterable<T>- See Also:
-
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>
-
minOptional
Description copied from interface:RichIterableReturns the minimum element out of this container based on the comparator as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
minOptionalin interfaceRichIterable<T>
-
maxOptional
Description copied from interface:RichIterableReturns the maximum element out of this container based on the comparator as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
maxOptionalin interfaceRichIterable<T>
-
minOptional
Description copied from interface:RichIterableReturns the minimum element out of this container based on the natural order as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
minOptionalin interfaceRichIterable<T>
-
maxOptional
Description copied from interface:RichIterableReturns the maximum element out of this container based on the natural order as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
maxOptionalin interfaceRichIterable<T>
-
minByOptional
public <V extends Comparable<? super V>> Optional<T> minByOptional(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 as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
minByOptionalin interfaceRichIterable<T>
-
maxByOptional
public <V extends Comparable<? super V>> Optional<T> maxByOptional(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 as an Optional. If the container is emptyOptional.empty()is returned.- Specified by:
maxByOptionalin interfaceRichIterable<T>
-