fun-menu

ncurses learning thing
git clone https://git.pastanoggin.com/fun-menu.git
Log | Files | Refs | README | LICENSE

cycle.h (977B)


      1 #ifndef CYCLE_H
      2 #define CYCLE_H
      3 
      4 // cycle
      5 typedef struct Cycle Cycle;
      6 
      7 /*
      8  * cycle_new: create a new cycling iterator 
      9  * parameters:
     10  * 	base (void *) -> pointer to start of array to cycle through
     11  * 	memb_n (size_t) -> number of elements of array 'base'
     12  * 	memb_size (size_t) -> size of an element of array 'base'
     13  * returns:
     14  * 	Cycle * -> the created cylce
     15  * 	NULL -> failed to allocate memory for cycle
     16  */
     17 Cycle *cycle_new(const void *base, size_t memb_n, size_t memb_size);
     18 
     19 /* cycle_free: free the cycle. doesn't free buffer pointed to by cycle->base */
     20 void cycle_free(Cycle *cycle);
     21 
     22 /* cycle_index: get index of current element of cycle */
     23 size_t cycle_index(Cycle *cycle);
     24 
     25 /* cycle_current: get current element of cycle */
     26 const void *cycle_current(Cycle *cycle);
     27 
     28 /* cycle_next: move cycle one element forward */
     29 const void *cycle_next(Cycle *cycle);
     30 
     31 /* cycle_free: move cycle one element backward*/
     32 const void *cycle_prev(Cycle *cycle);
     33 
     34 #endif /* CYCLE_H */