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()).
Extends
Section titled “Extends”Iterator<E>
Type Parameters
Section titled “Type Parameters”E
Methods
Section titled “Methods”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.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”UnsupportedOperationException if the list is unmodifiable
forEachRemaining()
Section titled “forEachRemaining()”forEachRemaining(
action):void
Defined in: src/interfaces/Iterator.ts:30
Calls action for each remaining element, in order, until the iterator is exhausted.
Parameters
Section titled “Parameters”action
Section titled “action”(e) => void
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if action is null
Inherited from
Section titled “Inherited from”hasNext()
Section titled “hasNext()”hasNext():
boolean
Defined in: src/interfaces/Iterator.ts:8
Returns true if next() would return an element.
Returns
Section titled “Returns”boolean
Inherited from
Section titled “Inherited from”hasPrevious()
Section titled “hasPrevious()”hasPrevious():
boolean
Defined in: src/interfaces/Iterator.ts:52
Returns true if previous() would return an element.
Returns
Section titled “Returns”boolean
next()
Section titled “next()”next():
E
Defined in: src/interfaces/Iterator.ts:15
Returns the next element and advances the cursor.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if there are no more elements
Throws
Section titled “Throws”ConcurrentModificationException if the collection was structurally modified other than through this iterator
Inherited from
Section titled “Inherited from”nextIndex()
Section titled “nextIndex()”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.
Returns
Section titled “Returns”number
previous()
Section titled “previous()”previous():
E
Defined in: src/interfaces/Iterator.ts:59
Returns the previous element and moves the cursor backwards.
Returns
Section titled “Returns”E
Throws
Section titled “Throws”NoSuchElementException if the cursor is at the start of the list
Throws
Section titled “Throws”ConcurrentModificationException if the list was structurally modified other than through this iterator
previousIndex()
Section titled “previousIndex()”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.
Returns
Section titled “Returns”number
remove()
Section titled “remove()”remove():
void
Defined in: src/interfaces/Iterator.ts:25
Removes the element last returned by next() from the underlying collection.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”IllegalStateException if next() has not been called, or remove() was already called after the
last next()
Throws
Section titled “Throws”UnsupportedOperationException if the collection is unmodifiable or the iterator does not support removal
Throws
Section titled “Throws”ConcurrentModificationException if the collection was structurally modified other than through this iterator
Inherited from
Section titled “Inherited from”set(
e):void
Defined in: src/interfaces/Iterator.ts:70
Replaces the element last returned by next() or previous() with e.
Parameters
Section titled “Parameters”E
Returns
Section titled “Returns”void
Throws
Section titled “Throws”IllegalStateException if neither next() nor previous() has been called, or remove() or
add() was called after the last one
Throws
Section titled “Throws”UnsupportedOperationException if the list does not support set