-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
37 lines (29 loc) · 1.06 KB
/
README
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
hashmap
-------
A simple hashmap in C. No license because I don't care enough - do whatever you
want with it. Uses FNV-1a hash and handles collisions through linked lists.
Values are simply stored as (void *), which means you can store a pointer
to whatever you want. Just remember what kind of data you're working with
and typecast accordingly when retrieving values.
READ THE HEADER FILE and change the options for your use case.
If any issues arise, simply open an issue.
Creating a Hashmap
------------------
Call hashmap_new(val_free_func).
val_free_func is should be a function that frees your values.
Use the macro hashmap_item_free_func() on your function to typecast it.
Creating and Adding an Item
------------------------------------
hashmap_insert(map, "key", value).
Retrieving an Item
------------------
Call hashmap_get(map, key).
Removing an Item
----------------
Call hashmap_remove(map, key);
Freeing
-------
Simply call hashmap_free(map) and everything should be freed recursively.
Return Values
-------------
Functions return 0 on success, and 1 on error.