parrotcode: A PIR-based Iterator Object | |
Contents | Libraries |
Iter -- A PIR-based Iterator Object
An iterator with an object-oriented interface, written in PIR. Currently implemented only for Array type PMCs. Expect Hash support shortly.
load_bytecode 'Iter.pir'
.local pmc iter
iter = new 'Iter'
## initialize the iterator
iter.'start'(your_aggregate)
## advance to the next item in the iterator
iter.'next'()
## check for exhaustion
$I0 = iter.'exhausted'()
if $I0 goto done
## get the value from the iterator
$P0 = iter.'value'()
## alternate interface to advance and get the value
$P0 = iter.'nextval'()
Iter
Methods .'start'(PMC aggregate)
.'next'()
value
attribute to the value of the next item from the iterator. Sets the internal exhausted
attribute if the iterator is exhausted..'exhausted'()
.'value'()
.'nextval'()
.'next'()
, and returns .'value'()
.Jerry Gay a.k.a. particle
|