Skip to content
Buy me a coffee

ListIterator

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

An iterator for lists that moves in both directions, reports its position, and can replace or insert elements. The cursor sits between elements: between previous() (index previousIndex()) and next() (index nextIndex()).

E

add(e): void

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

Inserts e immediately before the cursor: a following next() is unaffected and a following previous() returns e. After it, remove() and set() throw IllegalStateException until next() or previous() is called.

E

void

UnsupportedOperationException if the list is unmodifiable


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

Iterator.forEachRemaining


hasNext(): boolean

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

Returns true if next() would return an element.

boolean

Iterator.hasNext


hasPrevious(): boolean

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

Returns true if previous() 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

Iterator.next


nextIndex(): number

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

Returns the index of the element the next next() would return, or the list size at the end.

number


previous(): E

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

Returns the previous element and moves the cursor backwards.

E

NoSuchElementException if the cursor is at the start of the list

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


previousIndex(): number

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

Returns the index of the element the next previous() would return, or -1 at the start.

number


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

Iterator.remove


set(e): void

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

Replaces the element last returned by next() or previous() with e.

E

void

IllegalStateException if neither next() nor previous() has been called, or remove() or add() was called after the last one

UnsupportedOperationException if the list does not support set