Top Description Inners Fields Constructors Methods
org.eclipse.collections.impl.lazy

public Class CollectIterable<T, V>

extends AbstractLazyIterable<V>
Class Inheritance
Imports
java.util.Iterator, .Optional, org.eclipse.collections.api.block.function.Function, .Function2, org.eclipse.collections.api.block.function.primitive.DoubleObjectToDoubleFunction, .FloatObjectToFloatFunction, .IntObjectToIntFunction, .LongObjectToLongFunction, org.eclipse.collections.api.block.predicate.Predicate, org.eclipse.collections.api.block.procedure.Procedure, .Procedure2, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.impl.block.factory.Functions, .Predicates, org.eclipse.collections.impl.lazy.iterator.CollectIterator, org.eclipse.collections.impl.utility.Iterate

A CollectIterable is an iterable that transforms a source iterable using a function as it iterates.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Iterable<T>
private final Function<? super T, ? extends V>

Constructor Summary

AccessConstructor and Description
public
CollectIterable(Iterable<T> newAdapted, Function<? super T, ? extends V> function)

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfy.

Implements org.eclipse.collections.api.RichIterable.allSatisfy.

Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty.

public boolean
anySatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfy.

Implements org.eclipse.collections.api.RichIterable.anySatisfy.

Returns true if the predicate evaluates to true for any element of the iterable.

public V
detect(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detect.

Implements org.eclipse.collections.api.RichIterable.detect.

Returns the first element of the iterable for which the predicate evaluates to true or null in the case where no element returns true.

public Optional<V>
detectOptional(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectOptional.

Implements org.eclipse.collections.api.RichIterable.detectOptional.

Returns the first element of the iterable for which the predicate evaluates to true as an Optional.

public void
each(Procedure<? super V> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

The procedure is executed for each element in the iterable.

public <P> void
forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

The procedure2 is evaluated for each element in the iterable with the specified parameter provided as the second argument.

public void
forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure.

public V
public V
public <IV> IV
injectInto(IV injectedValue, Function2<? super IV, ? super V, ? extends IV> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public int
injectInto(int injectedValue, IntObjectToIntFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public long
injectInto(long injectedValue, LongObjectToLongFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public double
injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public float
injectInto(float injectedValue, FloatObjectToFloatFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters.

public boolean
public Iterator<V>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public boolean
noneSatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfy.

Implements org.eclipse.collections.api.RichIterable.noneSatisfy.

Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty.

public boolean
notEmpty()

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

The English equivalent of !this.isEmpty()

public int
size()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.size.

Implements org.eclipse.collections.api.RichIterable.size.

Returns the number of items in this iterable.

Inherited from org.eclipse.collections.impl.lazy.AbstractLazyIterable:
asLazychunkcollectcollectBooleancollectBytecollectCharcollectDoublecollectFloatcollectIfcollectIntcollectLongcollectShortcollectWithconcatenatedistinctdropdropWhileflatCollectgetOnlygroupBygroupByEachgroupByUniqueKeyintomaxByOptionalmaxOptionalmaxOptionalminByOptionalminOptionalminOptionalpartitionpartitionWithrejectrejectWithselectselectInstancesOfselectWithsumByDoublesumByFloatsumByIntsumByLongtaketakeWhiletaptoStackzipzipWithIndex

Field Detail

adaptedback to summary
private final Iterable<T> adapted
functionback to summary
private final Function<? super T, ? extends V> function

Constructor Detail

CollectIterableback to summary
public CollectIterable(Iterable<T> newAdapted, Function<? super T, ? extends V> function)

Method Detail

allSatisfyback to summary
public boolean allSatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.allSatisfy.

Implements org.eclipse.collections.api.RichIterable.allSatisfy.

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

Returns true if the predicate evaluates to true for every element of the iterable or if the iterable is empty. Otherwise, returns false.

Annotations
@Override
anySatisfyback to summary
public boolean anySatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.anySatisfy.

Implements org.eclipse.collections.api.RichIterable.anySatisfy.

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

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

Annotations
@Override
detectback to summary
public V detect(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detect.

Implements org.eclipse.collections.api.RichIterable.detect.

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

Returns 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"));
Annotations
@Override
detectOptionalback to summary
public Optional<V> detectOptional(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.detectOptional.

Implements org.eclipse.collections.api.RichIterable.detectOptional.

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

Returns 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"));

Annotations
@Override
eachback to summary
public void each(Procedure<? super V> procedure)

Implements org.eclipse.collections.api.RichIterable.each.

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

The 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 of InternalIterable#forEach(Procedure) that has a signature conflict with Iterable#forEach(java.util.function.Consumer).
Annotations
@Override
forEachWithback to summary
public <P> void forEachWith(Procedure2<? super V, ? super P> procedure, P parameter)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWith.

Implements org.eclipse.collections.api.InternalIterable.forEachWith.

Doc from org.eclipse.collections.api.InternalIterable.forEachWith.

The 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);
Annotations
@Override
forEachWithIndexback to summary
public void forEachWithIndex(ObjectIntProcedure<? super V> objectIntProcedure)

Overrides org.eclipse.collections.impl.AbstractRichIterable.forEachWithIndex.

Implements org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Doc from org.eclipse.collections.api.InternalIterable.forEachWithIndex.

Iterates 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());
    }
});
Annotations
@Override
getFirstback to summary
public V getFirst()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.getFirst.

Implements org.eclipse.collections.api.LazyIterable.getFirst, 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
getLastback to summary
public V getLast()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.getLast.

Implements org.eclipse.collections.api.RichIterable.getLast.

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

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

Annotations
@Override
injectIntoback to summary
public <IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super V, ? extends IV> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

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

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

Annotations
@Override
injectIntoback to summary
public int injectInto(int injectedValue, IntObjectToIntFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

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

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

Annotations
@Override
injectIntoback to summary
public long injectInto(long injectedValue, LongObjectToLongFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

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

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

Annotations
@Override
injectIntoback to summary
public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

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

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

Annotations
@Override
injectIntoback to summary
public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super V> f)

Overrides org.eclipse.collections.impl.AbstractRichIterable.injectInto.

Implements org.eclipse.collections.api.RichIterable.injectInto.

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

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

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.isEmpty.

Implements org.eclipse.collections.api.RichIterable.isEmpty.

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

Returns true if this iterable has zero items.

Annotations
@Override
iteratorback to summary
public Iterator<V> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Annotations
@Override
noneSatisfyback to summary
public boolean noneSatisfy(Predicate<? super V> predicate)

Overrides org.eclipse.collections.impl.AbstractRichIterable.noneSatisfy.

Implements org.eclipse.collections.api.RichIterable.noneSatisfy.

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

Returns true if the predicate evaluates to false for every element of the iterable or if the iterable is empty. Otherwise, returns false.

Annotations
@Override
notEmptyback to summary
public boolean notEmpty()

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

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

The English equivalent of !this.isEmpty()

Annotations
@Override
sizeback to summary
public int size()

Overrides org.eclipse.collections.impl.lazy.AbstractLazyIterable.size.

Implements org.eclipse.collections.api.RichIterable.size.

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

Returns the number of items in this iterable.

Annotations
@Override
org.eclipse.collections.impl.lazy back to summary

private final Class CollectIterable.AttributePredicate<T, V>

extends Object
implements Predicate<T>
Class Inheritance
  • java.lang.Object
  • org.eclipse.collections.impl.lazy.CollectIterable.AttributePredicate
All Implemented Interfaces
org.eclipse.collections.api.block.predicate.Predicate, java.io.Serializable, java.util.function.Predicate

Field Summary

Modifier and TypeField and Description
private final Function<? super T, ? extends V>
private transient V
private final Predicate<? super V>
private static final long

Constructor Summary

AccessConstructor and Description
private
AttributePredicate(Function<? super T, ? extends V> newFunction, Predicate<? super V> newPredicate)

Method Summary

Modifier and TypeMethod and Description
public boolean
public V
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

functionback to summary
private final Function<? super T, ? extends V> function
functionResultback to summary
private transient V functionResult
predicateback to summary
private final Predicate<? super V> predicate
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

AttributePredicateback to summary
private AttributePredicate(Function<? super T, ? extends V> newFunction, Predicate<? super V> newPredicate)

Method Detail

acceptback to summary
public boolean accept(T anObject)

Implements org.eclipse.collections.api.block.predicate.Predicate.accept.

Annotations
@Override
functionResultback to summary
public V functionResult()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override