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

public Class DistinctIterable<T>

extends AbstractLazyIterable<T>
Class Inheritance
Imports
java.util.Iterator, .Optional, org.eclipse.collections.api.LazyIterable, org.eclipse.collections.api.block.predicate.Predicate, org.eclipse.collections.api.block.procedure.Procedure, org.eclipse.collections.api.block.procedure.primitive.ObjectIntProcedure, org.eclipse.collections.api.factory.Sets, org.eclipse.collections.api.set.MutableSet, org.eclipse.collections.impl.block.procedure.AdaptObjectIntProcedureToProcedure, org.eclipse.collections.impl.lazy.iterator.DistinctIterator, org.eclipse.collections.impl.utility.Iterate

A DistinctIterable is an iterable that eliminates duplicates from a source iterable as it iterates.
Since
5.0

Field Summary

Modifier and TypeField and Description
private final Iterable<T>

Constructor Summary

AccessConstructor and Description
public
DistinctIterable(Iterable<T> newAdapted)

Method Summary

Modifier and TypeMethod and Description
public boolean
allSatisfy(Predicate<? super T> 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 T> 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 T
detect(Predicate<? super T> 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<T>
detectOptional(Predicate<? super T> 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 LazyIterable<T>
distinct()

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

Implements org.eclipse.collections.api.LazyIterable.distinct.

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

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

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

The procedure is executed for each element in the iterable.

public void
forEachWithIndex(ObjectIntProcedure<? super T> 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 Iterator<T>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

public boolean
noneSatisfy(Predicate<? super T> 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.

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

Field Detail

adaptedback to summary
private final Iterable<T> adapted

Constructor Detail

DistinctIterableback to summary
public DistinctIterable(Iterable<T> newAdapted)

Method Detail

allSatisfyback to summary
public boolean allSatisfy(Predicate<? super T> 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 T> 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 T detect(Predicate<? super T> 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<T> detectOptional(Predicate<? super T> 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
distinctback to summary
public LazyIterable<T> distinct()

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

Implements org.eclipse.collections.api.LazyIterable.distinct.

Doc from org.eclipse.collections.api.LazyIterable.distinct.

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

Annotations
@Override
eachback to summary
public void each(Procedure<? super T> 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
forEachWithIndexback to summary
public void forEachWithIndex(ObjectIntProcedure<? super T> 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
iteratorback to summary
public Iterator<T> 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 T> 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