µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
|
Iterators are data structures that wrap arbitrary collections of data and define ways of enumerating them. More...
Data Fields | |
void *(* | next )(uel_iterator_t *, void *) |
The iteration function assigned to this iterator type. More... | |
void * | collection |
A reference to the collection being iterated. | |
Iterators are data structures that wrap arbitrary collections of data and define ways of enumerating them.
This is an unspecialised structure that should be augumented with actual behaviour implementation.
In order to specialise it, create a struct that holds whatever state is meaningful to iteration and has a uel_iterator_t
as its first member. Then, whenever needed, cast the iterator to your custom type.
void*(* uel_iterator_t::next) (uel_iterator_t *, void *) |
The iteration function assigned to this iterator type.
This is the actual implementation of the iteration algorithm. It takes a reference to the iterator and the last accessed element's address and returns a reference to the next element.
To resquest the first collection item, pass NULL as the last element parameter. When this function returns NULL, there are no more elements in the collection to be iterated over.