public interface InternalIterable<T> extends Iterable<T>
Modifier and Type | Method and Description |
---|---|
void |
forEach(Procedure<? super T> procedure)
The procedure is executed for each element in the iterable.
|
<P> void |
forEachWith(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.
|
void |
forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Deprecated.
in 6.0. Use
OrderedIterable.forEachWithIndex(ObjectIntProcedure) instead. |
forEach, iterator, spliterator
void forEach(Procedure<? super T> procedure)
Example using a Java 8 lambda:
people.forEach(Procedures.cast(person -> LOGGER.info(person.getName())));
Example using an anonymous inner class:
people.forEach(new ProcedureNOTE: This method started to conflict with() { public void value(Person person) { LOGGER.info(person.getName()); } });
Iterable.forEach(java.util.function.Consumer)
since Java 1.8. It is recommended to use RichIterable.each(Procedure)
instead to avoid casting to Procedure.@Deprecated void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
OrderedIterable.forEachWithIndex(ObjectIntProcedure)
instead.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() { public void value(Person person, int index) { LOGGER.info("Index: " + index + " person: " + person.getName()); } });
<P> void forEachWith(Procedure2<? super T,? super P> procedure, P parameter)
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() { public void value(Person person, Person other) { if (person.isRelatedTo(other)) { LOGGER.info(person.getName()); } } }, fred);
Copyright © 2004–2016. All rights reserved.