planarbot/sortedmap.h

26 lines
664 B
C
Raw Normal View History

2022-11-01 22:09:32 +01:00
#ifndef SORTED_MAP
#define SORTED_MAP
enum nodetype { EMPTY, LEAF, INTERN };
2022-11-01 22:09:32 +01:00
typedef struct node {
enum nodetype type;
char * key;
union {
struct children {
struct node * l;
struct node * r;
} children;
void * value;
} content;
2022-11-01 22:09:32 +01:00
} 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));
2022-11-08 23:31:00 +01:00
void * free_mappair(void *acc, char *key, void *value);
void * free_mapitem(void *acc, char *key, void *value);
2022-11-01 22:09:32 +01:00
void free_map(SortedMap *this);
#endif