| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public default void | forEach(Consumer<? super T> consumer)
Overrides default java. Performs the given action for each element of the |
| public <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. |
| public void | forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Deprecated
in 6.0.
Iterates over the iterable passing each element and the current relative int index to the specified instance of ObjectIntProcedure. |
| forEach | back to summary |
|---|---|
| public void forEach(Procedure<? super T> procedure) The procedure is executed for each element in the iterable. Example using a Java 8 lambda: people.forEach(Procedures.cast(person -> LOGGER.info(person.getName()))); Example using an anonymous inner class:
people.forEach(new Procedure<Person>()
{
public void value(Person person)
{
LOGGER.info(person.getName());
}
});
NOTE: This method started to conflict with Iterable#forEach(java.
since Java 1.8. It is recommended to use RichIterable#each(Procedure) instead to avoid casting to Procedure.
| |
| forEach | back to summary |
|---|---|
| public default void forEach(Consumer<? super T> consumer) Overrides default java. Doc from java. Performs the given action for each element of the The behavior of this method is unspecified if the action performs side-effects that modify the underlying source of elements, unless an overriding class has specified a concurrent modification policy.
| |
| forEachWith | back to summary |
|---|---|
| public <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. 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);
| |
| forEachWithIndex | back to summary |
|---|---|
| public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
Deprecated in 6.0. Use 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());
}
});
| |