Iterable
interface Iterable<T : Any!>
java.lang.Iterable |
Implementing this interface allows an object to be the target of the enhanced for
statement (sometimes called the "for-each loop" statement).
Summary
Public methods | |
---|---|
open Unit |
Performs the given action for each element of the |
abstract MutableIterator<T> |
iterator() Returns an iterator over elements of type |
open Spliterator<T> |
Creates a |
Public methods
forEach
open fun forEach(action: Consumer<in T>): Unit
Performs the given action for each element of the Iterable
until all elements have been processed or the action throws an exception. Actions are performed in the order of iteration, if that order is specified. Exceptions thrown by the action are relayed to the caller.
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.
Parameters | |
---|---|
action |
Consumer<in T>: The action to be performed for each element |
Exceptions | |
---|---|
java.lang.NullPointerException |
if the specified action is null |
iterator
abstract fun iterator(): MutableIterator<T>
Returns an iterator over elements of type T
.
Return | |
---|---|
MutableIterator<T> |
an Iterator. |
spliterator
open fun spliterator(): Spliterator<T>
Creates a Spliterator
over the elements described by this Iterable
.
Return | |
---|---|
Spliterator<T> |
a Spliterator over the elements described by this Iterable . |