-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.h
More file actions
42 lines (32 loc) · 690 Bytes
/
map.h
File metadata and controls
42 lines (32 loc) · 690 Bytes
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
#ifndef MAP_H
#define MAP_H
#include <stddef.h>
#include <stdbool.h>
typedef struct Map Map;
typedef struct Entry Entry;
typedef void (*MapPutFunc)(Map *, const char *, void *);
typedef void *(*MapGetFunc)(Map *, const char *);
typedef void (*MapRemoveFunc)(Map *, const char *);
typedef void (*MapDestroyFunc)(Map *);
struct Entry
{
const char *key;
void *value;
Entry *next;
};
struct Map
{
size_t size;
Entry **buckets;
MapPutFunc put;
MapGetFunc get;
MapRemoveFunc remove;
MapDestroyFunc destroy;
};
typedef Map *(*MapEmptyFunc)(size_t capacity);
typedef struct
{
MapEmptyFunc empty;
} MapClass;
extern const MapClass MapFactory;
#endif