Skip to content
Buy me a coffee

Iterator

Defined in: src/interfaces/Iterator.ts:6

A cursor over a collection (hasNext/next/remove). Distinct from the JS iterator protocol, which collections also implement. Iterators returned by the library’s collections are fail-fast: after a structural change made other than through this iterator, the next step throws ConcurrentModificationException.

E

forEachRemaining(action): void

Defined in: src/interfaces/Iterator.ts:30

Calls action for each remaining element, in order, until the iterator is exhausted.

(e) => void

void

NullPointerException if action is null


hasNext(): boolean

Defined in: src/interfaces/Iterator.ts:8

Returns true if next() would return an element.

boolean


next(): E

Defined in: src/interfaces/Iterator.ts:15

Returns the next element and advances the cursor.

E

NoSuchElementException if there are no more elements

ConcurrentModificationException if the collection was structurally modified other than through this iterator


remove(): void

Defined in: src/interfaces/Iterator.ts:25

Removes the element last returned by next() from the underlying collection.

void

IllegalStateException if next() has not been called, or remove() was already called after the last next()

UnsupportedOperationException if the collection is unmodifiable or the iterator does not support removal

ConcurrentModificationException if the collection was structurally modified other than through this iterator