aboutsummaryrefslogtreecommitdiff
path: root/collections/map/map.c
diff options
context:
space:
mode:
authorTucker Evans <tucker@tuckerevans.com>2020-07-06 15:49:49 -0400
committerTucker Evans <tucker@tuckerevans.com>2020-07-08 10:56:36 -0400
commit50846316de122801e07511d4e3771a4561efa5ad (patch)
tree8f3edaafdeac9551781d823ac20f5c869a1d3c08 /collections/map/map.c
parentcf427c05b05e0409cfdeb6bc30b69070dd1700c3 (diff)
Add size function for maps
Diffstat (limited to 'collections/map/map.c')
-rw-r--r--collections/map/map.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/collections/map/map.c b/collections/map/map.c
index 803b5ad..712a895 100644
--- a/collections/map/map.c
+++ b/collections/map/map.c
@@ -25,3 +25,12 @@ cmp_func cmp;
return tmp;
}
+
+int map_size(root)
+map *root;
+{
+ if (!root || !root->key)
+ return 0;
+
+ return map_size(root->left) + map_size(root->right) + 1;
+}