blob: 96d98c1cee5226c6f590273955f8795630a626b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#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 */
|