No Matches
Data Fields | Related Symbols
as_arraylist_iterator Struct Reference

Detailed Description

Iterator for as_arraylist.

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

AS_EXTERN as_arraylist_iterator * as_arraylist_iterator_init(as_arraylist_iterator *iterator, const as_arraylist *list)
const as_arraylist * list

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

AS_EXTERN as_arraylist_iterator * as_arraylist_iterator_new(const as_arraylist *list)

To iterate, use as_arraylist_iterator_has_next() and as_arraylist_iterator_next():

const as_val * val = as_arraylist_iterator_next(&it);
AS_EXTERN bool as_arraylist_iterator_has_next(const as_arraylist_iterator *iterator)
AS_EXTERN const as_val * as_arraylist_iterator_next(as_arraylist_iterator *iterator)

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

AS_EXTERN void as_arraylist_iterator_destroy(as_arraylist_iterator *iterator)

The as_arraylist_iterator is a subtype of as_iterator. This allows you to alternatively use as_iterator functions, by typecasting as_arraylist_iterator to as_iterator.

while ( as_iterator_has_next(i) ) {
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_arraylist_iterator functions. So, calling as_iterator_destroy() is equivalent to calling as_arraylist_iterator_destroy().

Definition at line 88 of file as_arraylist_iterator.h.

#include "as_arraylist_iterator.h"

+ Inheritance diagram for as_arraylist_iterator:
+ Collaboration diagram for as_arraylist_iterator:

Data Fields

const as_arraylistlist
uint32_t pos
- 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_arraylist_iterator_destroy (as_arraylist_iterator *iterator)
AS_EXTERN bool as_arraylist_iterator_has_next (const as_arraylist_iterator *iterator)
AS_EXTERN as_arraylist_iteratoras_arraylist_iterator_init (as_arraylist_iterator *iterator, const as_arraylist *list)
AS_EXTERN as_arraylist_iteratoras_arraylist_iterator_new (const as_arraylist *list)
AS_EXTERN const as_valas_arraylist_iterator_next (as_arraylist_iterator *iterator)

Friends And Related Symbol Documentation

◆ as_arraylist_iterator_destroy()

AS_EXTERN void as_arraylist_iterator_destroy ( as_arraylist_iterator * iterator)

Destroy the iterator and releases resources used by the iterator.

iteratorThe iterator to release

◆ as_arraylist_iterator_has_next()

AS_EXTERN bool as_arraylist_iterator_has_next ( const as_arraylist_iterator * iterator)

Tests if there are more values available in the iterator.

iteratorThe iterator to be tested.
true if there are more values. Otherwise false.

◆ as_arraylist_iterator_init()

AS_EXTERN as_arraylist_iterator * as_arraylist_iterator_init ( as_arraylist_iterator * iterator,
const as_arraylist * list )

Initializes a stack allocated as_iterator for as_arraylist.

iteratorThe iterator to initialize.
listThe list to iterate.
On success, the initialized iterator. Otherwise NULL.

◆ as_arraylist_iterator_new()

AS_EXTERN as_arraylist_iterator * as_arraylist_iterator_new ( const as_arraylist * list)

Creates a new heap allocated as_iterator for as_arraylist.

listThe list to iterate.
On success, the new iterator. Otherwise NULL.

◆ as_arraylist_iterator_next()

AS_EXTERN const as_val * as_arraylist_iterator_next ( as_arraylist_iterator * iterator)

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

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

Field Documentation

◆ list

const as_arraylist* as_arraylist_iterator::list

The as_arraylist being iterated over

Definition at line 99 of file as_arraylist_iterator.h.

◆ pos

uint32_t as_arraylist_iterator::pos

The current position of the iteration

Definition at line 104 of file as_arraylist_iterator.h.

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