A minimal hashmap implimintation written in C.
Cmap includes all the basic features of a hashmap -
- Setting values
- Getting values
- Removing values
The most basic usage -
#include <cmap.h>
int main() {
struct cmap_hash_map *hmap = cmap_hash_map_new(16, NULL, NULL);
cmap_hash_set(hmap, "foo", "foo");
char *foo = hash_map_get("foo");
printf("The value is %s\n", foo);
return 0;
}
This program will produce the following output -
The value is foo
Currently, cmap only supports mapping of char*
-> void*
, though in the future I do intend to implement a generic version for any type of key.
The tests in this project are written with the help of the Mintest library