diff options
author | James Shaw <jshaw@netsurf-browser.org> | 2007-09-22 23:08:54 +0000 |
---|---|---|
committer | James Shaw <jshaw@netsurf-browser.org> | 2007-09-22 23:08:54 +0000 |
commit | 6b9b7ec69002e062bb48049acdab7e1e7145b0ca (patch) | |
tree | c746866823441f341bc873bcb951f67392f549e1 /test/lib/list.h | |
parent | b41f9b430878ea33ba8da7b30bfb6a81a4dd0317 (diff) | |
download | libdom-6b9b7ec69002e062bb48049acdab7e1e7145b0ca.tar.gz libdom-6b9b7ec69002e062bb48049acdab7e1e7145b0ca.tar.bz2 |
Extend list implementation, add test-list.c to test some of it.
svn path=/trunk/dom/; revision=3573
Diffstat (limited to 'test/lib/list.h')
-rw-r--r-- | test/lib/list.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/lib/list.h b/test/lib/list.h index a0a6c6a..7c27796 100644 --- a/test/lib/list.h +++ b/test/lib/list.h @@ -8,6 +8,10 @@ #ifndef list_h_ #define list_h_ +#include <stdbool.h> + +#include "comparators.h" + struct list_elt { void* data; struct list_elt* next; @@ -22,23 +26,32 @@ struct list { struct list* list_new(void); void list_destroy(struct list* list); -typedef int (*list_compare_func)(const void* a, const void* b); - /** * Add data to the tail of the list. */ void list_add(struct list* list, void* data); /** + * Remove element containing data from list. + * The list element is freed, but the caller must free the data itself + * if necessary. + * + * Returns true if data was found in the list. + */ +bool list_remove(struct list* list, void* data); + +struct list* list_clone(struct list* list); + +/** * Tests if data is equal to any element in the list. */ -bool list_contains(struct list* list, void* data, - int (*comparator)(const void* a, const void* b)); +bool list_contains(struct list* list, void* data, + comparator comparator); /** * Tests if superlist contains all elements in sublist. Order is not important. */ bool list_contains_all(struct list* superList, struct list* subList, - list_compare_func comparator); + comparator comparator); #endif |