Library / Collections / Sequences / ArrayIterator
ArrayIterator
Concrete BidirectionalIterator OF T for Array[T].
Constructors 1
INIT(REFERENCE T[] source)
constructor that requires a REFERENCE
The iterator never owns the vector — .source is a
REFERENCE field, not
an owning copy — so a const reference is the correct shape
and accepts both const-source (Array's iterator() is non-
mutating) and non-const-source call sites.
Methods 7
METHOD hasNext() RETURNS booleanreads
returns TRUE if we've not reached the end
MODIFY METHOD next() RETURNS | REFERENCE Tmodifies
Pipe-XOR: SUCCESS populates the value slot with a non-owning
reference; end-of-iteration populates STATUS with FAILURE.
a REFERENCE is non-owning, so referencing it is
harmless; only the by-value lift (popFirst/popLast) rejects opaque.
This matches Array.at, which has never guarded opaque.
METHOD peek() RETURNS | REFERENCE Treads
peek at the next item without advancing the iterator
MODIFY METHOD skip(uint64 n) RETURNS | REFERENCE Tmodifies
skip(n) — moves cursor forward by n positions. Parameter is unsigned per spec §Iterator (forward-only contract). Pipe-XOR: SUCCESS with the element at the new position, or FAILURE if out of bounds. skip(0) is equivalent to peek().
METHOD hasPrevious() RETURNS booleanreads
returns TRUE if the iterator is not at the first element
MODIFY METHOD previous() RETURNS | REFERENCE Tmodifies
mirror of next: on SUCCESS, it returns a REFERENCE to the value and decrements the iterator's cursor; on FAILURE it returns only the status message
MODIFY METHOD skipBack(uint64 n) RETURNS | REFERENCE Tmodifies
skipBack(n) — moves cursor backward by n positions. Symmetric counterpart to skip(n) on BidirectionalIterator. Pipe-XOR: SUCCESS with the element at the new position, or FAILURE if start is reached. skipBack(0) is equivalent to peek().