O2S C Library 1.8.2
Provide high-level data-structures and other fundamental tools for C projects
Loading...
Searching...
No Matches
iter.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* ____ _ _____ ____ _ _ _ _____ _ _ ____ ____ */
3/* / ___| / \ | ___| _ \ / \ | \ | | |_ _| || | | _ \/ ___| */
4/* \___ \ / _ \ | |_ | |_) | / _ \ | \| | | | | || |_| | | \___ \ */
5/* ___) / ___ \| _| | _ < / ___ \| |\ | | | |__ _| |_| |___) | */
6/* |____/_/ \_|_| |_| \_/_/ \_|_| \_| |_| |_| |____/|____/ */
7/* */
14/* ************************************************************************** */
15
16#include "private.h"
17
18#include "o2s/array.h"
19
21void array_iter(const array_t* self, void (*function)(void*))
22{
23 void* element = self->start;
24
25 while (element < array_end(self))
26 {
27 function(element);
28 element += self->type_size;
29 }
30}
void * array_end(const array_t *self)
One-past-the-end pointer of the array.
Definition getters.c:25
Internal state of a dynamic array.
Dynamic arrays.
void array_iter(const array_t *self, void(*function)(void *))
Call function on each element.
Definition iter.c:21
O2S array implementation.
Definition array.h:24
void * start
Underlying storage.
Definition array.h:25
size_t type_size
Size in bytes of a single element.
Definition array.h:26