#include "map.h" #include #include #include #include struct map_node { void *key, *val; cmp_func cmp; 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; } int map_size(root) map *root; { if (!root || !root->key) return 0; return map_size(root->left) + map_size(root->right) + 1; }