Author: jshaw
Date: Sat Sep 22 13:18:28 2007
New Revision: 3560
URL:
http://source.netsurf-browser.org?rev=3560&view=rev
Log:
Implement list_contains_all()
Modified:
trunk/dom/test/list.c
trunk/dom/test/list.h
Modified: trunk/dom/test/list.c
URL:
http://source.netsurf-browser.org/trunk/dom/test/list.c?rev=3560&r1=3...
==============================================================================
--- trunk/dom/test/list.c (original)
+++ trunk/dom/test/list.c Sat Sep 22 13:18:28 2007
@@ -62,3 +62,13 @@
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;
+}
Modified: trunk/dom/test/list.h
URL:
http://source.netsurf-browser.org/trunk/dom/test/list.h?rev=3560&r1=3...
==============================================================================
--- trunk/dom/test/list.h (original)
+++ trunk/dom/test/list.h Sat Sep 22 13:18:28 2007
@@ -32,4 +32,9 @@
*/
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