Iterator for as_orderedmap.
To use the iterator, you can either initialize a stack allocated variable, use as_orderedmap_iterator_init()
:
Or you can create a new heap allocated variable using as_orderedmap_iterator_new()
:
To iterate, use as_orderedmap_iterator_has_next()
and as_orderedmap_iterator_next()
:
When you are finished using the iterator, then you should release the iterator and associated resources:
The as_orderedmap_iterator
is a subtype of as_iterator
. This allows you to alternatively use as_iterator
functions, by typecasting as_orderedmap_iterator
to as_iterator
.
Each of the as_iterator
functions proxy to the as_orderedmap_iterator
functions. So, calling as_iterator_destroy()
is equivalent to calling as_orderedmap_iterator_destroy()
.
Notes:
as_orderedmap_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 181 of file as_orderedmap.h.
#include "as_orderedmap.h"
Data Fields | |
uint32_t | ix |
const as_orderedmap * | map |
as_pair | pair |
Data Fields inherited from as_iterator | |
void * | data |
const struct as_iterator_hooks_s * | hooks |
Related Functions | |
(Note that these are not member functions.) | |
AS_EXTERN void | as_orderedmap_iterator_destroy (as_orderedmap_iterator *it) |
AS_EXTERN bool | as_orderedmap_iterator_has_next (const as_orderedmap_iterator *it) |
AS_EXTERN as_orderedmap_iterator * | as_orderedmap_iterator_init (as_orderedmap_iterator *it, const as_orderedmap *map) |
AS_EXTERN as_orderedmap_iterator * | as_orderedmap_iterator_new (const as_orderedmap *map) |
AS_EXTERN const as_val * | as_orderedmap_iterator_next (as_orderedmap_iterator *it) |
|
related |
Destroy the iterator and releases resources used by the iterator.
it | The iterator to release |
|
related |
Tests if there are more values available in the iterator.
it | The iterator to be tested. |
|
related |
Initializes a stack allocated as_iterator for the given as_orderedmap.
it | The iterator to initialize. |
map | The map to iterate. |
|
related |
Creates a heap allocated as_iterator for the given as_orderedmap.
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.
it | The iterator to get the next value from. |
uint32_t as_orderedmap_iterator::ix |
Definition at line 185 of file as_orderedmap.h.
const as_orderedmap* as_orderedmap_iterator::map |
Definition at line 184 of file as_orderedmap.h.
as_pair as_orderedmap_iterator::pair |
Definition at line 186 of file as_orderedmap.h.