ListNodes[A: A, N: ListNode[A] #read]¶
Iterate over the nodes in a List
.
class ref ListNodes[A: A, N: ListNode[A] #read] is
Iterator[N] ref
Implements¶
- Iterator[N] ref
Constructors¶
create¶
Build the iterator over nodes.
reverse
of false
iterates forward, while
reverse
of true
iterates in reverse.
new ref create(
head: (N | None val),
reverse: Bool val = false)
: ListNodes[A, N] ref^
Parameters¶
Returns¶
- ListNodes[A, N] ref^
Public Functions¶
has_next¶
Indicates whether there are any nodes remaining in the iterator.
fun box has_next()
: Bool val
Returns¶
- Bool val
next¶
Return the next node in the iterator, advancing the iterator by one element.
Order of return is determined by reverse
argument during creation.
fun ref next()
: N ?
Returns¶
- N ?