diff options
author | Tucker Evans <tucker@tuckerevans.com> | 2020-07-08 20:53:06 -0400 |
---|---|---|
committer | Tucker Evans <tucker@tuckerevans.com> | 2020-07-08 20:53:06 -0400 |
commit | a2ff97d2a7d14266c22a64224e62934c610b4cd5 (patch) | |
tree | fc89b13df0876374af2bd56b9806793ac4ce2841 | |
parent | af1c42d4bf235779d05c135a87f2c95c83df6940 (diff) |
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.
-rw-r--r-- | collections/map/map.c | 11 |
1 files changed, 6 insertions, 5 deletions
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); |