NAME
src/pmc/arrayiterator.pmc - ArrayIterator PMC
DESCRIPTION
Generic iterator for traversing arrays.
SYNOPSIS
default usage
    .local pmc iterator, array, entry
    iterator = iter array
  iter_loop:
    unless iterator, iter_end  # while (more values)
    entry = shift iterator     # get an entry
    ...
    goto iter_loop
  iter_end:
iterate from the end, for arrays
    .local pmc iterator, array, entry
    iterator = iter array
    iterator = .ITERATE_FROM_END
  iter_loop:
    unless iterator, iter_end  # while (more values)
    entry = pop iterator     # get an entry
    ...
    goto iter_loop
  iter_end:
Warning!
NB: for different direction you have to use different ops!
TODO: Discuss idea of having separate get_iter/get_reverse_iter VTABLEs to avoid this caveat.
Vtable functions
- void init()Raises an exception. Use
- void init_pmc(PMC *initializer)Initializes the iterator with an aggregate PMC. Defaults iteration mode to iterate from start.
- void mark()Marks the current idx/key and the aggregate as live.
- PMC *clone()
- INTVAL get_bool()Returns true if there is more elements to iterate over.
- INTVAL elements()Returns the number of remaining elements in the array.
- void set_integer_native(INTVAL value)Reset the Iterator.
- PMC *get_pmc()Returns this Iterator's array.
- INTVAL shift_integer()Returns the element for the current idx and sets the idx to the next one.
- FLOATVAL shift_float()
- STRING *shift_string()
- PMC *shift_pmc()Returns the element for the current idx/key and sets the idx/key to the next one.
- INTVAL pop_integer()Returns the element for the current idx and sets the idx to the next one.
- FLOATVAL pop_float()
- STRING *pop_string()
- PMC *pop_pmc()Returns the element for the current idx/key and sets the idx/key to the next one.
- PMC *get_pmc_keyed(PMC *key)Returns the element for
- PMC *get_pmc_keyed_int(INTVAL key)Returns the element for
- INTVAL get_integer_keyed(PMC *key)
- INTVAL get_integer_keyed_int(INTVAL idx)Get integer value of current position plus idx.
- FLOATVAL get_number_keyed(PMC *key)
- FLOATVAL get_number_keyed_int(INTVAL idx)Get number value of current position plus idx.
- STRING *get_string_keyed(PMC *key)
- STRING *get_string_keyed_int(INTVAL idx)Get string value of current position plus idx.
- INTVAL exists_keyed(PMC *key)Returns whether an element for
- INTVAL exists_keyed_int(INTVAL idx)Returns whether an element for
- INTVAL defined_keyed(PMC *key)
- INTVAL defined_keyed_int(INTVAL key)Returns the result of calling
init_pmc().
value must be one of
ITERATE_FROM_START ... Iterate from start ITERATE_FROM_END ... Iterate from end
*key.
key.
*key exists in the array.
idx exists in the aggregate.
defined_keyed(key) on the aggregate.Auxiliar functions
- static void out_of_bounds(PARROT_INTERP)Throw out-of-bounds exception.
