![]() |
Iterator for as_hashmap.
To use the iterator, you can either initialize a stack allocated variable, use as_hashmap_iterator_init()
:
Or you can create a new heap allocated variable using as_hashmap_iterator_new()
:
To iterate, use as_hashmap_iterator_has_next()
and as_hashmap_iterator_next()
:
When you are finished using the iterator, then you should release the iterator and associated resources:
The as_hashmap_iterator
is a subtype of as_iterator
. This allows you to alternatively use as_iterator
functions, by typecasting as_hashmap_iterator
to as_iterator
.
Each of the as_iterator
functions proxy to the as_hashmap_iterator
functions. So, calling as_iterator_destroy()
is equivalent to calling as_hashmap_iterator_destroy()
.
Notes:
as_hashmap_iterator_next() returns an as_pair pointer. The as_pair contains the key and value pointers of the current map element. This one as_pair "container" is re-used for all the iterations, i.e. the contents will be overwritten and are only valid until the next iteration.
Definition at line 98 of file as_hashmap_iterator.h.
#include "as_hashmap_iterator.h"
Data Fields | |
uint32_t | count |
as_hashmap_element * | curr |
uint32_t | extras_pos |
const as_hashmap * | map |
as_pair | pair |
uint32_t | table_pos |
![]() | |
void * | data |
const struct as_iterator_hooks_s * | hooks |
Related Functions | |
(Note that these are not member functions.) | |
void | as_hashmap_iterator_destroy (as_hashmap_iterator *iterator) |
bool | as_hashmap_iterator_has_next (const as_hashmap_iterator *iterator) |
as_hashmap_iterator * | as_hashmap_iterator_init (as_hashmap_iterator *iterator, const as_hashmap *map) |
as_hashmap_iterator * | as_hashmap_iterator_new (const as_hashmap *map) |
const as_val * | as_hashmap_iterator_next (as_hashmap_iterator *iterator) |
|
related |
Destroy the iterator and releases resources used by the iterator.
iterator | The iterator to release |
|
related |
Tests if there are more values available in the iterator.
iterator | The iterator to be tested. |
|
related |
Initializes a stack allocated as_iterator for the given as_hashmap.
iterator | The iterator to initialize. |
map | The map to iterate. |
|
related |
Creates a heap allocated as_iterator for the given as_hashmap.
map | The map to iterate. |
|
related |
Attempts to get the next value from the iterator. This will return the next value, and iterate past the value.
iterator | The iterator to get the next value from. |
uint32_t as_hashmap_iterator::count |
Internal counters
Definition at line 115 of file as_hashmap_iterator.h.
as_hashmap_element* as_hashmap_iterator::curr |
Current entry
Definition at line 110 of file as_hashmap_iterator.h.
uint32_t as_hashmap_iterator::extras_pos |
Definition at line 117 of file as_hashmap_iterator.h.
const as_hashmap* as_hashmap_iterator::map |
The hashmap
Definition at line 105 of file as_hashmap_iterator.h.
as_pair as_hashmap_iterator::pair |
Last returned key & value
Definition at line 122 of file as_hashmap_iterator.h.
uint32_t as_hashmap_iterator::table_pos |
Definition at line 116 of file as_hashmap_iterator.h.