-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.h
50 lines (37 loc) · 752 Bytes
/
map.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* map.h
*
* Created on: Jan 31, 2024
* Author: gibbonec
*/
#ifndef MAP_H_
#define MAP_H_
#include "array.h"
#include <stdlib.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
const char* prefix;
size_t prefixLen;
enum {LEAF, TREE} type;
union {
Array* tree;
void* leaf;
} value;
} Map;
typedef enum {
MAP_ALLOC_ERR = _ArrayErrN,
_MapErrN,
} MapErr;
Map* newMap(void);
void destroyMap(Map* map, void (*freeValue)(void*));
bool mapIsEmpty(Map* map);
MapErr mapInsert(Map* map, const char* key, size_t keyLen, void* value);
void* mapGet(const Map* map, const char* key, size_t keyLen);
void testMap(void);
#ifdef __cplusplus
}
#endif
#endif /* MAP_H_ */