hash.c 2 review

by rbytes.net on

hash.c is a C hash table with quadratic probing

License: BSD License
File size: 4K
Developer: David Crawshaw
0 stars award from rbytes.net

hash.c is a C hash table with quadratic probing. hash.c is very small and easy to use.

Compile: gcc -c hash.c

This hashtable uses C-strings for keys and quadratic probing instead of linked-list chains. It depends only on ANSI C and so should work anywhere.


hash * hash_new ( unsigned int size ) Create new hashtable.
void hash_destroy ( hash *h ) Free hashtable.
int hash_add ( hash *h , const char *key , void *value ) Add key/value pair.
void * hash_get ( hash *h , const char *key ) Return value matching given key.
void * hash_remove ( hash *h , const char *key ) Remove key from table, returing value.
unsigned int hash_size ( hash *h ) Returns total number of keys.

What's New in This Release:
This release uses exponentiation instead of xor in hashing.
It adds a hash_destroy function.

hash.c 2 keywords