All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Data Fields | Related Functions
as_hashmap_iterator Struct Reference

Detailed Description

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():

const as_val * val = as_hashmap_iterator_next(&it);
}

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"

+ Inheritance diagram for as_hashmap_iterator:
+ Collaboration diagram for as_hashmap_iterator:

Data Fields

uint32_t count
 
as_hashmap_elementcurr
 
uint32_t extras_pos
 
const as_hashmapmap
 
as_pair pair
 
uint32_t table_pos
 
- Data Fields inherited from as_iterator
void * data
 
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_iteratoras_hashmap_iterator_init (as_hashmap_iterator *iterator, const as_hashmap *map)
 
as_hashmap_iteratoras_hashmap_iterator_new (const as_hashmap *map)
 
const as_valas_hashmap_iterator_next (as_hashmap_iterator *iterator)
 

Friends And Related Function Documentation

void as_hashmap_iterator_destroy ( as_hashmap_iterator iterator)
related

Destroy the iterator and releases resources used by the iterator.

Parameters
iteratorThe iterator to release
bool as_hashmap_iterator_has_next ( const as_hashmap_iterator iterator)
related

Tests if there are more values available in the iterator.

Parameters
iteratorThe iterator to be tested.
Returns
true if there are more values. Otherwise false.
as_hashmap_iterator * as_hashmap_iterator_init ( as_hashmap_iterator iterator,
const as_hashmap map 
)
related

Initializes a stack allocated as_iterator for the given as_hashmap.

Parameters
iteratorThe iterator to initialize.
mapThe map to iterate.
Returns
On success, the initialized iterator. Otherwise NULL.
as_hashmap_iterator * as_hashmap_iterator_new ( const as_hashmap map)
related

Creates a heap allocated as_iterator for the given as_hashmap.

Parameters
mapThe map to iterate.
Returns
On success, the new iterator. Otherwise NULL.
const as_val * as_hashmap_iterator_next ( as_hashmap_iterator iterator)
related

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

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

Field Documentation

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.


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