NAME
src/pmc/hashiterator.pmc - HashIterator PMC
DESCRIPTION
Generic iterator for traversing a Hash PMC.
SYNOPSIS
default usage
.local pmc iterator, hash, key, entry iterator = iter hash iter_loop: unless iterator, iter_end # while (more values) key = shift iterator # get the key. Some key entry = hash[key] ... goto iter_loop iter_end:
C++-style usage
.local pmc iterator, hash, iter_key, key, entry iterator = iter hash iter_loop: unless iterator, iter_end # while (more values) iter_key = shift iterator # get the key key = iter_key.'key'() # get an original key used to put value key = iter_key.'value'() # get an entry ... goto iter_loop iter_end:
Methods
static void advance_to_next(PMC *self)
Advance to next position. Return found (if any) HashBucket.
void init_pmc(PMC *initializer)
Initializes the iterator with an aggregate PMC. Defaults iteration mode to iterate from start.
void mark()
Marks the hash as live.
PMC *clone()
void set_integer_native()
PMC *get_pmc()
Returns this Iterator's Hash.
INTVAL get_bool()
Returns true if there is more elements to iterate over.
INTVAL elements()
Returns the number of remaining elements in the Hash.
PMC *shift_pmc()
Returns the HashIteratorKey for the current position and advance the next one.