I work on ez_hash as an intellectual exercise.
Here's an example of how to use it:
#include
#include "ez_hash.h"
int usage(char* exename) {
printf("usage: %s key value\n", exename);
return(0);
};
int main(int argc, char *argv[]) {
ez_hash_table *my_hash;
if (argc != 3) {usage(argv[0]); return(1);};
// Initialize with 2^16 buckets. Min argument is 0. Max argument is 31.
my_hash = ez_hash_init(16);
// Insert a key-value pair.
printf("The hashcode is %u\n", ez_hash_set(my_hash, argv[1], argv[2]));
// Retrieve a value for a given key.
printf("Looking up key %s returns %s\n", argv[1], ez_hash_get(my_hash, argv[1]));
return(0);
}
The ez_hash library uses the FNV algorithm and source code.
Both the FNV algorithm and source code are in the public domain.
See the file fnv.h included with this software.