From a33e3badad7fbfa7e229f009c5c1b78c552a935b Mon Sep 17 00:00:00 2001 From: "S. Christoffer Eliesen" Date: Wed, 18 Nov 2015 21:12:20 +0100 Subject: list: Add list_seq_find. Sometimes one has to traverse a list to find out if some data already exists there in order to avoid dupilcates in the list, and this function facilitates in that without requiring that the data is ordered. --- include/list.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/list.h') diff --git a/include/list.h b/include/list.h index aff6800f..90d0ad36 100644 --- a/include/list.h +++ b/include/list.h @@ -15,5 +15,8 @@ void list_del(list_t *list, int index); void list_cat(list_t *list, list_t *source); // See qsort void list_sort(list_t *list, int compare(const void *left, const void *right)); +// Return index for first item in list that returns 0 for given compare +// function or -1 if none matches. +int list_seq_find(list_t *list, int compare(const void *item, const void *cmp_to), const void *cmp_to); #endif -- cgit v1.2.3-54-g00ecf