PeekingIterator

Decorates an iterator to support one-element lookahead while iterating.

The decorator supports the removal operation, but an IllegalStateException will be thrown if remove, add, set} is called directly after a call to peek or element.

Since

4.0

Parameters

<E>

the type of elements returned by this iterator.

Constructors

Link copied to clipboard
constructor(iterator: ListIterator<E>)
Constructor.
constructor(list: List<E>)
Constructor.

Functions

Link copied to clipboard
open fun add(e: E)
Link copied to clipboard
open fun currentIndex(): Int
Link copied to clipboard
open fun element(): E
Returns the next element in iteration without advancing the underlying iterator.
Link copied to clipboard
open fun forEachRemaining(action: Consumer<in E>)
Link copied to clipboard
open fun hasNext(): Boolean
Link copied to clipboard
open fun hasPrevious(): Boolean
Link copied to clipboard
open fun next(): E
Link copied to clipboard
open fun nextIndex(): Int
Link copied to clipboard
open fun peek(): E
Returns the next element in iteration without advancing the underlying iterator.
Link copied to clipboard
open fun <E> peekingIterator(iterator: ListIterator<E>): PeekingIterator<E>
Decorates the specified iterator to support one-element lookahead.
Link copied to clipboard
open fun previous(): E
Link copied to clipboard
open fun previousIndex(): Int
Link copied to clipboard
open fun remove()
Link copied to clipboard
open fun set(e: E)