PeekingIterator

interface PeekingIterator<out T : Any> : Iterator<T> (source)

An Iterator which provides the peek function in addition.

Types

Link copied to clipboard
object Companion

Necessary so that extension methods can extend it.

Functions

Link copied to clipboard
inline fun <T> Iterator<T>.forEachRemaining(operation: (T) -> Unit)

Performs the given operation on each remaining element.

Link copied to clipboard
abstract operator fun hasNext(): Boolean
Link copied to clipboard
fun <T, R> Iterator<T>.mapRemaining(transform: (T) -> R): List<R>

Maps remaining values of this Iterator with the help of the given transform functions, returns an empty list if Iterator.hasNext returns false for the first call.

Link copied to clipboard
fun <T, R> Iterator<T>.mapRemainingWithCounter(transform: (index: Int, T) -> R): List<R>

Maps remaining values of this Iterator with the help of the given transform functions where a counter variable is passed ot the transform function starting by 0; returns an empty list if Iterator.hasNext returns false for the first call.

Link copied to clipboard
abstract operator fun next(): T
Link copied to clipboard
abstract fun peek(): T

Returns the next element without consuming it.

Link copied to clipboard

Wraps this Iterator into a PeekingIterator and returns it.