From a2ff97d2a7d14266c22a64224e62934c610b4cd5 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Wed, 8 Jul 2020 20:53:06 -0400 Subject: Fix key comparisons where backwards Didn't affect anything other than being backwards to how binary trees are classically visualized i.e. left sub trees are less than a node and right sub trees are greater than. --- collections/map/map.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'collections/map') diff --git a/collections/map/map.c b/collections/map/map.c index 5de4ae3..747d6ce 100644 --- a/collections/map/map.c +++ b/collections/map/map.c @@ -88,7 +88,7 @@ void *key, *val; if (!root) return -1; - cmp = cmpf(root->key, key); + cmp = cmpf(key, root->key); if (cmp < 0) { @@ -145,11 +145,12 @@ cmp_func cmpf; void *key, *val; { int cmp; + void *tmp; if (!root) return NULL; - cmp = cmpf(root->key, key); + cmp = cmpf(key, root->key); if (cmp < 0) return map_set_val_aux(root->left, cmpf, key, val); @@ -182,7 +183,7 @@ void *key; if(!root) return 0; - cmp = cmpf(root->key, key); + cmp = cmpf(key, root->key); if (cmp < 0) return map_check_key_ptr_aux(root->left, cmpf, key); @@ -213,7 +214,7 @@ void *key; if (!root) return NULL; - cmp = cmpf(root->key, key); + cmp = cmpf(key, root->key); if (cmp < 0) return map_set_key_aux(root->left, cmpf, key); @@ -247,7 +248,7 @@ void *key; if (!root) return NULL; - cmp = cmpf(root->key, key); + cmp = cmpf(key, root->key); if (cmp < 0) return map_index_aux(root->left, cmpf, key); -- cgit v1.1