Loading...
Searching...
No Matches
Data Fields | Related Symbols
as_orderedmap_iterator Struct Reference

Detailed Description

Iterator for as_orderedmap.

To use the iterator, you can either initialize a stack allocated variable, use as_orderedmap_iterator_init():

const as_orderedmap * map
AS_EXTERN as_orderedmap_iterator * as_orderedmap_iterator_init(as_orderedmap_iterator *it, const as_orderedmap *map)

Or you can create a new heap allocated variable using as_orderedmap_iterator_new():

AS_EXTERN as_orderedmap_iterator * as_orderedmap_iterator_new(const as_orderedmap *map)

To iterate, use as_orderedmap_iterator_has_next() and as_orderedmap_iterator_next():

}
AS_EXTERN const as_val * as_orderedmap_iterator_next(as_orderedmap_iterator *it)
AS_EXTERN bool as_orderedmap_iterator_has_next(const as_orderedmap_iterator *it)

When you are finished using the iterator, then you should release the iterator and associated resources:

AS_EXTERN void as_orderedmap_iterator_destroy(as_orderedmap_iterator *it)

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.

}
static const as_val * as_iterator_next(as_iterator *iterator)
AS_EXTERN void as_iterator_destroy(as_iterator *iterator)
static bool as_iterator_has_next(const as_iterator *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"

+ Inheritance diagram for as_orderedmap_iterator:
+ Collaboration diagram for as_orderedmap_iterator:

Data Fields

uint32_t ix
 
const as_orderedmapmap
 
as_pair pair
 
- Data Fields inherited from as_iterator
void * data
 
const struct as_iterator_hooks_s * hooks
 

Related Symbols

(Note that these are not member symbols.)

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_iteratoras_orderedmap_iterator_init (as_orderedmap_iterator *it, const as_orderedmap *map)
 
AS_EXTERN as_orderedmap_iteratoras_orderedmap_iterator_new (const as_orderedmap *map)
 
AS_EXTERN const as_valas_orderedmap_iterator_next (as_orderedmap_iterator *it)
 

Friends And Related Symbol Documentation

◆ as_orderedmap_iterator_destroy()

AS_EXTERN void as_orderedmap_iterator_destroy ( as_orderedmap_iterator * it)
related

Destroy the iterator and releases resources used by the iterator.

Parameters
itThe iterator to release

◆ as_orderedmap_iterator_has_next()

AS_EXTERN bool as_orderedmap_iterator_has_next ( const as_orderedmap_iterator * it)
related

Tests if there are more values available in the iterator.

Parameters
itThe iterator to be tested.
Returns
true if there are more values. Otherwise false.

◆ as_orderedmap_iterator_init()

AS_EXTERN as_orderedmap_iterator * as_orderedmap_iterator_init ( as_orderedmap_iterator * it,
const as_orderedmap * map )
related

Initializes a stack allocated as_iterator for the given as_orderedmap.

Parameters
itThe iterator to initialize.
mapThe map to iterate.
Returns
On success, the initialized iterator. Otherwise NULL.

◆ as_orderedmap_iterator_new()

AS_EXTERN as_orderedmap_iterator * as_orderedmap_iterator_new ( const as_orderedmap * map)
related

Creates a heap allocated as_iterator for the given as_orderedmap.

Parameters
mapThe map to iterate.
Returns
On success, the new iterator. Otherwise NULL.

◆ as_orderedmap_iterator_next()

AS_EXTERN const as_val * as_orderedmap_iterator_next ( as_orderedmap_iterator * it)
related

Attempts to get the next value from the iterator. This will return the next value, and iterate past the value.

Parameters
itThe iterator to get the next value from.
Returns
The next value in the list if available. Otherwise NULL.

Field Documentation

◆ ix

uint32_t as_orderedmap_iterator::ix

Definition at line 185 of file as_orderedmap.h.

◆ map

const as_orderedmap* as_orderedmap_iterator::map

Definition at line 184 of file as_orderedmap.h.

◆ pair

as_pair as_orderedmap_iterator::pair

Definition at line 186 of file as_orderedmap.h.


The documentation for this struct was generated from the following file: