gdl_find, gdl_find_next, gdl_ctxfind, gdl_ctxfind_next 3 | 2016-03-06 | genlist manual |
---|
gdl_find - find an element on the list using a callback
typedef int (*cmpfunc)(itemtype *listelem, void *data);
void gdl_find(gdl_list_t *list, void *data, itemtype *elem, cmpfunc compar, itemtype **result)
void gdl_find_next(gdl_list_t *list, itemtype *elem, void *data, itemtype *elem, cmpfunc compar, itemtype **result)
typedef int (*ctxcmpfunc)(void *ctx, itemtype *listelem, void *data);
void gdl_ctxfind(gdl_list_t *list, void *data, itemtype *elem, ctxcmpfunc compar, void *ctx, itemtype **result)
void gdl_ctxfind_next(gdl_list_t *list, itemtype *elem, void *data, itemtype *elem, ctxcmpfunc compar, void *ctx, itemtype **result)
gdl_find finds the first list item that matches data according to the user provided compar callback and loads the item's pointer in *result. gdl_find_next continues (or starts) the search from the next element of elem. If there's no (more) match, NULL is loaded in *result.The compar function should return 0 on match.
gdl_ctxfind and gdl_ctxfind_next perform the same action with an extra, user provided context pointer passed to the compar.
These calls are implemented as function-like macros evaluating to void.
Arguments:
list A list to be checked. May not be NULL. data Data passed as the last argument to compar. elem The search should start from the next item after elem. May not be NULL. compar User provided function that returns 0 when data matches the current list element. ctx User provided context passed to compar. result Loaded with NULL if no element matched or with the pointer of the matching element.
gdl_find, gdl_find_next, gdl_ctxfind, gdl_ctxfind_next 3 | 2016-03-06 | genlist manual |
---|