aboutsummaryrefslogtreecommitdiffstats
path: root/README
blob: a00fff584e409e6e022c410fbd5cc55b6504e36c (plain) (blame)
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
Cheesemap
====

Cheesemap is a swiss-table like HashMap implementation in C. It's designed to be fast but also easy to understand and improve.
The HashMap might be a little memory efficient especially right after resizes and doesn't yet provide a shrink method. The HashMap
is not yet production tested but fully working.

* Example
```
#include "cheesemap.h"
#include <stdint.h>
#include <string.h>
#include <stddef.h>

struct user_info {
	const char* country;
	int age;
	int zip;	
};

uint64_t hash(const uint8_t* key) {
	const char* name = (const char*)key;
	uint64_t count;
	while(*name) {
		count++;
		name++;
	}

	return count;
}

bool compare(const uint8_t* key1, const uint8_t* key2) {
	const char* name1 = (const char*)key1;
	const char* name2 = (const char*)key2;
	return strcmp(name1, name2);
}

int main() {
	struct cheesemap map;
	cm_new(&map, sizeof(const char*), _Alignof(const char*), sizeof(struct user_info), _Alignof(struct user_info), NULL
}	
```