Commit 1867ef3e authored by Tinu Weber's avatar Tinu Weber

Add list_find

parent 824728e1
......@@ -43,6 +43,14 @@ list_destroy(struct list *l)
free(l);
}
void *
list_find(struct list *l, void *e, bool (*f)(void *le, void *e))
{
if (!f)
die("list_find(): f == NULL");
return l->elements[list_find_index(l, e, f)];
}
int unsigned
list_find_index(struct list *l, void *e, bool (*f)(void *le, void *e))
{
......
......@@ -20,6 +20,7 @@ void list_append(struct list *l, void *e);
bool list_contains(struct list *l, void *e, bool (*f)(void *le, void *e));
struct list *list_create(void);
void list_destroy(struct list *l);
void *list_find(struct list *l, void *e, bool (*f)(void *le, void *e));
int unsigned list_find_index(struct list *l, void *e,
bool (*f)(void *le, void *e));
void list_insert(struct list *l, void *e, int unsigned index);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment