46 #define IteratorTail(return_type, struct_type) \ 47 return_type (*const iterator_function)(struct_type *it); \ 48 void (*const destructor)(void *it); \ 74 #define IterationHead(it) \ 76 it->phase = !(it->phase) 111 #define IteratorInitHead(advance, ...) {.iterator_function = &advance, AddDestructor(no_destructor), __VA_ARGS__} 145 #define AddDestructor(func) ExtendInit(destructor, (void (*const)(void *)) &func) 168 #define ExtendInit(name, value) .name = value 180 #define next(state) (*(state.iterator_function))(&state) 192 #define next_p(state) (*(state->iterator_function))(state) 207 #define free_iterator(it) (*(it.destructor))(&it) 222 #define free_iterator_p(it) (*(it->destructor))(it) 261 uintmax_t ret = i->
idx;
262 intmax_t step = i->
step;
264 if ((step > 0 && i->
idx >= i->
stop) || (step < 0 && i->idx <= i->stop)) {
void no_destructor(void *it)
Definition: iterator.h:19
uintmax_t idx
The current position of the counter.
Definition: iterator.h:244
uintmax_t stop
The value before which the counter will stop.
Definition: iterator.h:245
bool started
An indicator that the iterator has started.
Definition: iterator.h:232
#define IteratorInitHead(advance,...)
The base macro for all iterator initialization functions in this project.
Definition: iterator.h:111
#define IteratorTail(return_type, struct_type)
The base definition macro for all iterators in this project.
Definition: iterator.h:46
bool exhausted
An indicator that the iterator has stopped.
Definition: iterator.h:231
intmax_t step
The amount by which the counter will move.
Definition: iterator.h:246
counter count_by(uintmax_t start, uintmax_t stop, intmax_t step)
Definition: iterator.h:280
#define ExtendInit(name, value)
The extension macro for initializing more complicated Iterators.
Definition: iterator.h:168
counter count_to(uintmax_t stop)
Definition: iterator.h:310
bool phase
An indicator that changes each time the iterator moves.
Definition: iterator.h:233
An implementation of Python-like iterators and generators in C.
Definition: iterator.h:230
#define IterationHead(it)
The base macro for all iteration functions in this project.
Definition: iterator.h:74
counter count_in_range(uintmax_t start, uintmax_t stop)
Definition: iterator.h:298
static uintmax_t iterate_counter(counter *i)
Definition: iterator.h:259
Definition: iterator.h:15
The reference struct for all iterators in this project.
Definition: iterator.h:243