#ifndef CYCLE_H #define CYCLE_H // cycle typedef struct Cycle Cycle; /* * cycle_new: create a new cycling iterator * parameters: * base (void *) -> pointer to start of array to cycle through * memb_n (size_t) -> number of elements of array 'base' * memb_size (size_t) -> size of an element of array 'base' * returns: * Cycle * -> the created cylce * NULL -> failed to allocate memory for cycle */ Cycle *cycle_new(const void *base, size_t memb_n, size_t memb_size); /* cycle_free: free the cycle. doesn't free buffer pointed to by cycle->base */ void cycle_free(Cycle *cycle); /* cycle_index: get index of current element of cycle */ size_t cycle_index(Cycle *cycle); /* cycle_current: get current element of cycle */ const void *cycle_current(Cycle *cycle); /* cycle_next: move cycle one element forward */ const void *cycle_next(Cycle *cycle); /* cycle_free: move cycle one element backward*/ const void *cycle_prev(Cycle *cycle); #endif /* CYCLE_H */