aboutsummaryrefslogtreecommitdiff
path: root/collections/map/map.c
diff options
context:
space:
mode:
Diffstat (limited to 'collections/map/map.c')
-rw-r--r--collections/map/map.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index 7de58e4..0600c8b 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -105,6 +105,25 @@ void *key;
return tmp;
}
+void* map_index(root, key)
+map *root;
+void *key;
+{
+ int cmp;
+ if (!root || !key)
+ return NULL;
+
+ cmp = root->cmp(root->key, key);
+
+ if (cmp < 0)
+ return map_index(root->left, key);
+
+ if (cmp > 0)
+ return map_index(root->right, key);
+
+ return root->val;
+}
+
void map_clear(root)
map *root;
{