25 lines
590 B
C
25 lines
590 B
C
#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_mapvalues(SortedMap *this);
|
|
void free_map(SortedMap *this);
|
|
#endif
|