| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #ifndef SL_LIST_H__
- # define SL_LIST_H__
- # define SL_LIST_BUFLEN 8
- struct sl_list_item {
- void *data[SL_LIST_BUFLEN];
- struct sl_list_item *next;
- };
- typedef struct {
- unsigned int count;
- struct sl_list_item *first;
- } sl_list;
- /**
- * Allocate a new list and return it
- * result should be unallocated with sllist_destroy()
- **/
- sl_list *sllist_create();
- /**
- * Free all ressources allocated by sllist_create
- **/
- void sllist_destroy(sl_list *list);
- /**
- * Get the numbers of items contained in sl_list
- **/
- unsigned int sllist_count(const sl_list * const list);
- /**
- * Add an item at the end of the list
- **/
- sl_list *sllist_pushback(sl_list *list, void *item);
- /**
- * Remove the last item of the list and return it
- **/
- void *sllist_popback(sl_list *list);
- /**
- * Get the item at position %pos
- **/
- void *sllist_at(const sl_list * const list, unsigned int pos);
- /**
- * Remove the item at position %pos, and return it
- * TODO
- **/
- void *sllist_removeat(sl_list *list, unsigned int pos);
- /**
- * Remove all elements
- **/
- sl_list *sllist_clear(sl_list *list);
- /**
- * Return index of first item, using compare fnc
- * Return -1 on failure
- * TODO
- **/
- int sllist_find(sl_list *list, int(*fnc)(const void *cmp, const void *param), const void *param);
- /**
- * Execute function foreach values of list
- * Param 2 is custom_data
- * A -1 return value will act as a `break` instruction
- * return the number of iterated objects
- **/
- int sllist_foreach(sl_list *list, int(*fnc)(void **item, void *custom), void *custom);
- #endif /* SL_LIST_H__ */
|