forked from fogleman/Craft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.h
More file actions
33 lines (26 loc) · 642 Bytes
/
map.h
File metadata and controls
33 lines (26 loc) · 642 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
#ifndef _map_h_
#define _map_h_
#define EMPTY_ENTRY(e) (!(e)->x && !(e)->y && !(e)->z && !(e)->w)
#define MAP_FOR_EACH(map, entry) \
for (unsigned int i = 0; i <= map->mask; i++) { \
Entry *entry = map->data + i; \
if (EMPTY_ENTRY(entry)) { \
continue; \
}
#define END_MAP_FOR_EACH }
typedef struct {
int x;
int y;
int z;
int w;
} Entry;
typedef struct {
unsigned int mask;
unsigned int size;
Entry *data;
} Map;
void map_alloc(Map *map);
void map_free(Map *map);
void map_set(Map *map, int x, int y, int z, int w);
int map_get(Map *map, int x, int y, int z);
#endif