summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Shaw <jshaw@netsurf-browser.org>2007-09-22 12:18:28 +0000
committerJames Shaw <jshaw@netsurf-browser.org>2007-09-22 12:18:28 +0000
commitfc296a5c6be6f150ec68c01fba9379dd696aaee4 (patch)
treefcbdc9fb11e9ee373bb93253367d41f448444330
parent59c42c0d15f702a803ad7377df2cc33c64459c36 (diff)
downloadlibdom-fc296a5c6be6f150ec68c01fba9379dd696aaee4.tar.gz
libdom-fc296a5c6be6f150ec68c01fba9379dd696aaee4.tar.bz2
Implement list_contains_all()
svn path=/trunk/dom/; revision=3560
-rw-r--r--test/list.c10
-rw-r--r--test/list.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/test/list.c b/test/list.c
index c2d098f..18b7d01 100644
--- a/test/list.c
+++ b/test/list.c
@@ -62,3 +62,13 @@ bool list_contains(struct list* list, void* data, int (*comparator)(const void*
return false;
}
+bool list_contains_all(struct list* superList, struct list* subList, int (*comparator)(const void* a, const void* b)) {
+ struct list_elt* elt = subList->head;
+ while (elt != NULL) {
+ if (!list_contains(superList, elt->data, comparator)) {
+ return false;
+ }
+ elt = elt->next;
+ }
+ return true;
+}
diff --git a/test/list.h b/test/list.h
index 444f5c8..5732032 100644
--- a/test/list.h
+++ b/test/list.h
@@ -32,4 +32,9 @@ void list_add(struct list* list, void* data);
*/
bool list_contains(struct list* list, void* data, int (*comparator)(const void* a, const void* b));
+/**
+ * Tests if superlist contains all elements in sublist. Order is not important.
+ */
+bool list_contains_all(struct list* superList, struct list* subList, int (*comparator)(const void* a, const void* b));
+
#endif