Add pmap_contains_bi() and pmap_remove_bi().
authorDavid Given <dg@cowlark.com>
Mon, 12 Dec 2016 22:56:49 +0000 (23:56 +0100)
committerDavid Given <dg@cowlark.com>
Mon, 12 Dec 2016 22:56:49 +0000 (23:56 +0100)
modules/src/data/pmap.c
modules/src/data/pmap.h

index a74febc..5eaadc2 100644 (file)
@@ -90,6 +90,12 @@ void pmap_remove(void* mapp, void* left, void* right)
     }
 }
 
+void pmap_remove_bi(void* mapp, void* left, void* right)
+{
+    pmap_remove(mapp, left, right);
+    pmap_remove(mapp, right, left);
+}
+
 void pmap_remove_either(void* mapp, void* either)
 {
     struct pmap* map = mapp;
@@ -106,6 +112,22 @@ void pmap_remove_either(void* mapp, void* either)
     }
 }
 
+bool pmap_contains_bi(void* mapp, void* left, void* right)
+{
+    struct pmap* map = mapp;
+    int i;
+
+    for (i=0; i<map->count; i++)
+    {
+        struct pmap_node* node = &map->item[i];
+               if (((node->left == left) && (node->right == right))
+            || ((node->left == right) && (node->right == left)))
+                       return true;
+    }
+
+       return NULL;
+}
+
 void* pmap_findleft(void* mapp, void* left)
 {
     struct pmap* map = mapp;
index c9939dc..9d4ec33 100644 (file)
@@ -27,7 +27,9 @@ extern void pmap_put(void* map, void* left, void* right);
 extern void pmap_add(void* map, void* left, void* right);
 extern void pmap_add_bi(void* map, void* left, void* right);
 extern void pmap_remove(void* map, void* left, void* right);
+extern void pmap_remove_bi(void* map, void* left, void* right);
 extern void pmap_remove_either(void* map, void* either);
+extern bool pmap_contains_bi(void* map, void* left, void* right);
 extern void* pmap_findleft(void* map, void* left);
 extern void* pmap_findright(void* map, void* right);