From cf427c05b05e0409cfdeb6bc30b69070dd1700c3 Mon Sep 17 00:00:00 2001 From: Tucker Evans Date: Mon, 6 Jul 2020 15:39:08 -0400 Subject: Add constructor for maps --- collections/map/map.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'collections/map/map.c') diff --git a/collections/map/map.c b/collections/map/map.c index 21af21c..803b5ad 100644 --- a/collections/map/map.c +++ b/collections/map/map.c @@ -1,7 +1,9 @@ #include "map.h" #include +#include #include +#include struct map_node { void *key, *val; @@ -9,3 +11,17 @@ struct map_node { struct map_node *left, *right, *parent; }; + +map* map_new(cmp) +cmp_func cmp; +{ + map *tmp; + + tmp = malloc(sizeof(map)); + assert(tmp); + + tmp->cmp = cmp; + tmp->key = tmp->val = tmp->left = tmp->right = tmp->parent = NULL; + + return tmp; +} -- cgit v1.1