|
PebbleOS
|
Generic bidirectional iterator over caller-defined state. More...
Data Structures | |
| struct | Iterator |
| Iterator. More... | |
Macros | |
| #define | ITERATOR_EMPTY ((Iterator){0, 0, 0}) |
| Iterator without callbacks or state. | |
Typedefs | |
| typedef void * | IteratorState |
| Iterator state, owned by the caller. | |
| typedef bool(* | IteratorCallback) (IteratorState state) |
| Step function of an iterator. | |
Functions | |
| void | iter_init (Iterator *iter, IteratorCallback next, IteratorCallback prev, IteratorState state) |
| Initialize an iterator. | |
| bool | iter_next (Iterator *iter) |
| Move to the next element. | |
| bool | iter_prev (Iterator *iter) |
| Move to the previous element. | |
Generic bidirectional iterator over caller-defined state.
Gives iteration a consistent shape and lets unit tests drive it.
| struct Iterator |
| Data Fields | ||
|---|---|---|
| IteratorCallback | next | Moves to the next element. |
| IteratorCallback | prev | Moves to the previous element. |
| IteratorState | state | State passed to the callbacks. |
| typedef bool(* IteratorCallback) (IteratorState state) |
Step function of an iterator.
| state | Iterator state, updated in place. |
| typedef void* IteratorState |
Iterator state, owned by the caller.
| void iter_init | ( | Iterator * | iter, |
| IteratorCallback | next, | ||
| IteratorCallback | prev, | ||
| IteratorState | state | ||
| ) |
| bool iter_next | ( | Iterator * | iter | ) |
Move to the next element.
| iter | Iterator, with a next callback. |