-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhashmap.h
More file actions
58 lines (49 loc) · 1.13 KB
/
hashmap.h
File metadata and controls
58 lines (49 loc) · 1.13 KB
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
51
52
53
54
55
56
57
58
#ifndef HASHMAP_C_
#define HASHMAP_C_
#ifndef GROW_THRESHOLD
#define GROW_THRESHOLD 0.7
#endif
#ifndef SHRINK_THRESHOLD
#define SHRINK_THRESHOLD 0.25
#endif
#ifndef MIN_SIZE
#define MIN_SIZE 1024
#endif
#ifndef MAX_SIZE
#define MAX_SIZE 65536
#endif
#ifndef TIME_TO_LIVE
#define TIME_TO_LIVE 250
#endif
#include <stdint.h>
#include <stddef.h>
#include <raymath.h>
#include <stdlib.h>
typedef struct chunk_t {
Vector2 index;
int *state;
int *nextState;
size_t alive;
size_t newAlive;
size_t timeToLive;
struct chunk_t *next;
} chunk_t;
typedef struct map_t {
chunk_t **slots;
size_t size;
size_t taken;
} map_t;
uint64_t map(int x, int y);
map_t createMap(size_t);
chunk_t *createChunk(Vector2, size_t);
int freeChunkList(chunk_t *);
chunk_t *search(chunk_t *head, Vector2 index);
chunk_t *insert(map_t *, Vector2, size_t);
int deleteMap(map_t *);
int updateChunk(map_t *, chunk_t *, Vector2, size_t, int, int);
int getCellValue_(const chunk_t *, Vector2, size_t);
int getCellValue(map_t , const chunk_t *, Vector2, size_t);
void printMap(map_t);
int drop(map_t *, Vector2);
chunk_t *find(map_t, Vector2);
#endif