You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
664 B

#ifndef SORTED_MAP
#define SORTED_MAP
enum nodetype { EMPTY, LEAF, INTERN };
typedef struct node {
enum nodetype type;
char * key;
union {
struct children {
struct node * l;
struct node * r;
} children;
void * value;
} content;
} SortedMap;
SortedMap * map();
void * get_map(SortedMap *this, char *key);
SortedMap * put_map(SortedMap *this, char *key, void *value);
void print_map(SortedMap *this);
void * fold_map(SortedMap *this, void * init, void * (*f)(void * acc, char *key, void *value));
void * free_mappair(void *acc, char *key, void *value);
void * free_mapitem(void *acc, char *key, void *value);
void free_map(SortedMap *this);