Top Description Methods
org.eclipse.collections.api

public Interface LazyIterable<T>

extends RichIterable<T>
Imports
java.util.Collection, org.eclipse.collections.api.bag.ImmutableBag, .MutableBag, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.BooleanFunction, .ByteFunction, .CharFunction, .DoubleFunction, .FloatFunction, .IntFunction, .LongFunction, .ShortFunction, org.eclipse.collections.api.block.predicate.Predicate, .Predicate2, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.factory.Bags, .Lists, .Sets, org.eclipse.collections.api.list.ImmutableList, .MutableList, org.eclipse.collections.api.ordered.OrderedIterable, org.eclipse.collections.api.set.ImmutableSet, .MutableSet, org.eclipse.collections.api.tuple.Pair

A LazyIterable is RichIterable which will defer evaluation for certain methods like select, reject, collect, etc. Any methods that do not return a LazyIterable when called will cause evaluation to be forced.
Since
1.0

Method Summary

Modifier and TypeMethod and Description
public LazyIterable<RichIterable<T>>
chunk(int size)

Redeclares org.eclipse.collections.api.RichIterable.chunk.

Creates a deferred chunk iterable.

public <V> LazyIterable<V>
collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collect.

Creates a deferred iterable for collecting elements from the current iterable.

public LazyBooleanIterable
collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectBoolean.

Returns a lazy BooleanIterable which will transform the underlying iterable data to boolean values based on the booleanFunction.

public LazyByteIterable
collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectByte.

Returns a lazy ByteIterable which will transform the underlying iterable data to byte values based on the byteFunction.

public LazyCharIterable
collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectChar.

Returns a lazy CharIterable which will transform the underlying iterable data to char values based on the charFunction.

public LazyDoubleIterable
collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectDouble.

Returns a lazy DoubleIterable which will transform the underlying iterable data to double values based on the doubleFunction.

public LazyFloatIterable
collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectFloat.

Returns a lazy FloatIterable which will transform the underlying iterable data to float values based on the floatFunction.

public <V> LazyIterable<V>
collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf.

Creates a deferred iterable for selecting and collecting elements from the current iterable.

public LazyIntIterable
collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectInt.

Returns a lazy IntIterable which will transform the underlying iterable data to int values based on the intFunction.

public LazyLongIterable
collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectLong.

Returns a lazy LongIterable which will transform the underlying iterable data to long values based on the longFunction.

public LazyShortIterable
collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectShort.

Returns a lazy ShortIterable which will transform the underlying iterable data to short values based on the shortFunction.

public <P, V> LazyIterable<V>
collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith.

Same as collect(Function) with a Function2 and specified parameter which is passed to the block.

public LazyIterable<T>
concatenate(Iterable<T> iterable)

Creates a deferred iterable that will join this iterable with the specified iterable.

public LazyIterable<T>
distinct()

Creates a deferred distinct iterable to get distinct elements from the current iterable.

public LazyIterable<T>
drop(int count)

Creates a deferred drop iterable for the current iterable using the specified count as the limit.

public LazyIterable<T>
dropWhile(Predicate<? super T> predicate)

public <V> LazyIterable<V>
flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.flatCollect.

Creates a deferred flattening iterable for the current iterable.

public default <P, V> LazyIterable<V>
flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

public T
getFirst()

Redeclares org.eclipse.collections.api.RichIterable.getFirst.

Returns the first element of an iterable.

public <R extends Collection<T>> R
into(R target)

Redeclares org.eclipse.collections.api.RichIterable.into.

Iterates over this iterable adding all elements into the target collection.

public LazyIterable<T>
reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.RichIterable.reject.

Creates a deferred iterable for rejecting elements from the current iterable.

public <P> LazyIterable<T>
rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public LazyIterable<T>
select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.RichIterable.select.

Creates a deferred iterable for selecting elements from the current iterable.

public <S> LazyIterable<S>
selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.RichIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

public <P> LazyIterable<T>
selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

public LazyIterable<T>
take(int count)

Creates a deferred take iterable for the current iterable using the specified count as the limit.

public LazyIterable<T>
takeWhile(Predicate<? super T> predicate)

public LazyIterable<T>
tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.RichIterable.tap.

Creates a deferred tap iterable.

public default Object[]
toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Converts this iterable to an array.

public default <E> E[]
toArray(E[] array)

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.

public default ImmutableBag<T>
toImmutableBag()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableBag.

Converts the RichIterable to the default ImmutableBag implementation.

public default ImmutableList<T>
toImmutableList()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableList.

Converts the RichIterable to the default ImmutableList implementation.

public default ImmutableSet<T>
toImmutableSet()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableSet.

Converts the RichIterable to the default ImmutableSet implementation.

public <S> LazyIterable<Pair<T, S>>
zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.RichIterable.zip.

Creates a deferred zip iterable.

public LazyIterable<Pair<T, Integer>>
zipWithIndex()

Redeclares org.eclipse.collections.api.RichIterable.zipWithIndex.

Creates a deferred zipWithIndex iterable.

Inherited from org.eclipse.collections.api.RichIterable:
aggregateByaggregateByaggregateInPlaceByallSatisfyallSatisfyWithanySatisfyanySatisfyWithappendStringappendStringappendStringasLazycollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithcontainscontainsAllcontainsAllArgumentscontainsAllIterablecontainsAnycontainsAnyIterablecontainsBycontainsNonecontainsNoneIterablecountcountBycountBycountByEachcountByEachcountByWithcountByWithcountWithdetectdetectIfNonedetectOptionaldetectWithdetectWithIfNonedetectWithOptionaleachflatCollectflatCollectBooleanflatCollectByteflatCollectCharflatCollectDoubleflatCollectFloatflatCollectIntflatCollectLongflatCollectShortflatCollectWithforEachgetAnygetLastgetOnlygroupBygroupBygroupByAndCollectgroupByEachgroupByEachgroupByUniqueKeygroupByUniqueKeyinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoinjectIntoDoubleinjectIntoFloatinjectIntoIntinjectIntoLongisEmptymakeStringmakeStringmakeStringmakeStringmaxmaxmaxBymaxByOptionalmaxOptionalmaxOptionalminminminByminByOptionalminOptionalminOptionalnoneSatisfynoneSatisfyWithnotEmptypartitionpartitionWithreducereduceByreduceByreduceInPlacereduceInPlacerejectrejectWithselectselectWithsizesumByDoublesumByFloatsumByIntsumByLongsummarizeDoublesummarizeFloatsummarizeIntsummarizeLongsumOfDoublesumOfFloatsumOfIntsumOfLongtoBagtoBiMaptoImmutableBiMaptoImmutableMaptoImmutableSortedBagtoImmutableSortedBagtoImmutableSortedBagBytoImmutableSortedListtoImmutableSortedListtoImmutableSortedListBytoImmutableSortedSettoImmutableSortedSettoImmutableSortedSetBytoListtoMaptoMaptoSettoSortedBagtoSortedBagtoSortedBagBytoSortedListtoSortedListtoSortedListBytoSortedMaptoSortedMaptoSortedMapBytoSortedSettoSortedSettoSortedSetBytoStringzipzipWithIndex

Method Detail

chunkback to summary
public LazyIterable<RichIterable<T>> chunk(int size)

Redeclares org.eclipse.collections.api.RichIterable.chunk.

Creates a deferred chunk iterable.

Annotations
@Override
collectback to summary
public <V> LazyIterable<V> collect(Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collect.

Creates a deferred iterable for collecting elements from the current iterable.

Annotations
@Override
collectBooleanback to summary
public LazyBooleanIterable collectBoolean(BooleanFunction<? super T> booleanFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectBoolean.

Returns a lazy BooleanIterable which will transform the underlying iterable data to boolean values based on the booleanFunction.

Annotations
@Override
collectByteback to summary
public LazyByteIterable collectByte(ByteFunction<? super T> byteFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectByte.

Returns a lazy ByteIterable which will transform the underlying iterable data to byte values based on the byteFunction.

Annotations
@Override
collectCharback to summary
public LazyCharIterable collectChar(CharFunction<? super T> charFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectChar.

Returns a lazy CharIterable which will transform the underlying iterable data to char values based on the charFunction.

Annotations
@Override
collectDoubleback to summary
public LazyDoubleIterable collectDouble(DoubleFunction<? super T> doubleFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectDouble.

Returns a lazy DoubleIterable which will transform the underlying iterable data to double values based on the doubleFunction.

Annotations
@Override
collectFloatback to summary
public LazyFloatIterable collectFloat(FloatFunction<? super T> floatFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectFloat.

Returns a lazy FloatIterable which will transform the underlying iterable data to float values based on the floatFunction.

Annotations
@Override
collectIfback to summary
public <V> LazyIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function)

Redeclares org.eclipse.collections.api.RichIterable.collectIf.

Creates a deferred iterable for selecting and collecting elements from the current iterable.

Annotations
@Override
collectIntback to summary
public LazyIntIterable collectInt(IntFunction<? super T> intFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectInt.

Returns a lazy IntIterable which will transform the underlying iterable data to int values based on the intFunction.

Annotations
@Override
collectLongback to summary
public LazyLongIterable collectLong(LongFunction<? super T> longFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectLong.

Returns a lazy LongIterable which will transform the underlying iterable data to long values based on the longFunction.

Annotations
@Override
collectShortback to summary
public LazyShortIterable collectShort(ShortFunction<? super T> shortFunction)

Redeclares org.eclipse.collections.api.RichIterable.collectShort.

Returns a lazy ShortIterable which will transform the underlying iterable data to short values based on the shortFunction.

Annotations
@Override
collectWithback to summary
public <P, V> LazyIterable<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.collectWith.

Doc from org.eclipse.collections.api.RichIterable.collectWith.

Same as collect(Function) with a Function2 and 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));
Annotations
@Override
concatenateback to summary
public LazyIterable<T> concatenate(Iterable<T> iterable)

Creates a deferred iterable that will join this iterable with the specified iterable.

distinctback to summary
public LazyIterable<T> distinct()

Creates a deferred distinct iterable to get distinct elements from the current iterable.

Since
5.0
dropback to summary
public LazyIterable<T> drop(int count)

Creates a deferred drop iterable for the current iterable using the specified count as the limit.

dropWhileback to summary
public LazyIterable<T> dropWhile(Predicate<? super T> predicate)
Since
8.0
See Also
OrderedIterable#dropWhile(Predicate)
flatCollectback to summary
public <V> LazyIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function)

Redeclares org.eclipse.collections.api.RichIterable.flatCollect.

Creates a deferred flattening iterable for the current iterable.

Annotations
@Override
flatCollectWithback to summary
public default <P, V> LazyIterable<V> flatCollectWith(Function2<? super T, ? super P, ? extends Iterable<V>> function, P parameter)

Overrides default org.eclipse.collections.api.RichIterable.flatCollectWith.

Doc from org.eclipse.collections.api.RichIterable.flatCollectWith.

Same as flatCollect, only with a Function2 that is passed an extra parameter.

Annotations
@Override
Since
9.2
getFirstback to summary
public T getFirst()

Redeclares org.eclipse.collections.api.RichIterable.getFirst.

Doc from org.eclipse.collections.api.RichIterable.getFirst.

Returns 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.

Annotations
@Override
intoback to summary
public <R extends Collection<T>> R into(R target)

Redeclares org.eclipse.collections.api.RichIterable.into.

Iterates over this iterable adding all elements into the target collection.

Annotations
@Override
rejectback to summary
public LazyIterable<T> reject(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.RichIterable.reject.

Creates a deferred iterable for rejecting elements from the current iterable.

Annotations
@Override
rejectWithback to summary
public <P> LazyIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.rejectWith.

Doc from org.eclipse.collections.api.RichIterable.rejectWith.

Similar to reject(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> rejected =
    people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18));
Annotations
@Override
selectback to summary
public LazyIterable<T> select(Predicate<? super T> predicate)

Redeclares org.eclipse.collections.api.RichIterable.select.

Creates a deferred iterable for selecting elements from the current iterable.

Annotations
@Override
selectInstancesOfback to summary
public <S> LazyIterable<S> selectInstancesOf(Class<S> clazz)

Redeclares org.eclipse.collections.api.RichIterable.selectInstancesOf.

Doc from org.eclipse.collections.api.RichIterable.selectInstancesOf.

Returns all elements of the source collection that are instances of the Class clazz.

RichIterable<Integer> integers =
    List.mutable.with(new Integer(0), new Long(0L), new Double(0.0)).selectInstancesOf(Integer.class);
Annotations
@Override
selectWithback to summary
public <P> LazyIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)

Redeclares org.eclipse.collections.api.RichIterable.selectWith.

Doc from org.eclipse.collections.api.RichIterable.selectWith.

Similar to select(Predicate), except with an evaluation parameter for the second generic argument in Predicate2.

E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

Example using a Java 8 lambda expression:

RichIterable<Person> selected =
    people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18));
Annotations
@Override
takeback to summary
public LazyIterable<T> take(int count)

Creates a deferred take iterable for the current iterable using the specified count as the limit.

takeWhileback to summary
public LazyIterable<T> takeWhile(Predicate<? super T> predicate)
Since
8.0
See Also
OrderedIterable#takeWhile(Predicate)
tapback to summary
public LazyIterable<T> tap(Procedure<? super T> procedure)

Redeclares org.eclipse.collections.api.RichIterable.tap.

Creates a deferred tap iterable.

Annotations
@Override
toArrayback to summary
public default Object[] toArray()

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Doc from org.eclipse.collections.api.RichIterable.toArray.

Converts this iterable to an array.

Annotations
@Override
toArrayback to summary
public default <E> E[] toArray(E[] array)

Overrides default org.eclipse.collections.api.RichIterable.toArray.

Doc from org.eclipse.collections.api.RichIterable.toArray.

Converts this iterable to an array using the specified target array, assuming the target array is as long or longer than the iterable.

Annotations
@Override
toImmutableBagback to summary
public default ImmutableBag<T> toImmutableBag()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableBag.

Doc from org.eclipse.collections.api.RichIterable.toImmutableBag.

Converts the RichIterable to the default ImmutableBag implementation.

Annotations
@Override
toImmutableListback to summary
public default ImmutableList<T> toImmutableList()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableList.

Doc from org.eclipse.collections.api.RichIterable.toImmutableList.

Converts the RichIterable to the default ImmutableList implementation.

Annotations
@Override
toImmutableSetback to summary
public default ImmutableSet<T> toImmutableSet()

Overrides default org.eclipse.collections.api.RichIterable.toImmutableSet.

Doc from org.eclipse.collections.api.RichIterable.toImmutableSet.

Converts the RichIterable to the default ImmutableSet implementation.

Annotations
@Override
zipback to summary
public <S> LazyIterable<Pair<T, S>> zip(Iterable<S> that)

Redeclares org.eclipse.collections.api.RichIterable.zip.

Creates a deferred zip iterable.

Annotations
@Override
zipWithIndexback to summary
public LazyIterable<Pair<T, Integer>> zipWithIndex()

Redeclares org.eclipse.collections.api.RichIterable.zipWithIndex.

Creates a deferred zipWithIndex iterable.

Annotations
@Override