Simple hash table in C
Note: This is not intended for production use.
This hash table implementation allows you to specify how many "buckets" it will use. Each bucket is a linked list for simplicity. This could be extended to point to an array, which might provide a little better performance. Keys and values added are not copied, so it's up to the caller to manage those pointers.
Operations:
- create - with specified number of buckets
- destroy - frees all allocated memory
- add/set a key/value
- remove a key/value
- retrieve value for a key
Compile and execute the binary to run the demo use case in main.c:
gcc *.c ./a.out
You should see:
hello -> world color -> blue
hello -> goodbye color -> blue
color -> blue