About Libhashish
Libhashish is a powerful and generic hash library for C and C++. The library attempt to combine the best algorithms in this area and take all kinds of optimizations into account. Furthermore the main focus is applicability - at least you should use and feel comfortable with this library. See the following list for some details:
- Build-in key support for char arrays (strings) and uint_{8,16,32} types and support for own (possible complex) key data types
- Support rbtree's as collision strategy instead of bucked lists (avoid worst case O(n) scenario)
- Dynamic or manual adjustable table size (reordering if proportion entries/table_size is unfavorable)
- Build as an static or dynamic library (.a and .so)
- Iterator support (equivalent to ruby's hash.each() method)
- Thread clean - fine-grained lock mechanisms (mutex locks, reader writer locks, ...)
- Bloom filter implementation
- Many built-in hash algorithms (from trivial algorithms till cryptographic ones)
- Architecture clean - runs on 32bit machines as well as 64bit machines
- As lightweight as possible - no bloated code
- Makefile test target plus benchmark applications for comparing the different hashing algorithm
- Dual licensed under the GNU General Public and BSD License (see Documentation to make the BSD License active)
Use the source, Luke
The following code snippset demonstrate a trivial but complete example how to use libhashish. There are really a bunch of other - more specialized - usages but for the normal case (keys of type char array (string)) these standard calls are sufficing:
/* gcc -pipe -Os -Wall -W test.c -lm -lhashish -o test */ #include <libhashish.h> int main(void) { hi_handle_t *hi_handle; const char *key = "23"; const char *data = "data element"; const char *data_ptr; /* initialize hashish handle */ hi_init_str(&hi_handle, 23); /* insert an key/data pair */ ret = hi_insert_str(hi_handle, key, data); /* search for a pair with a string key and store result */ hi_get_str(hi_handle, key, &data_ptr); fprintf(stdout, "Key: %s Data: %s\n", key, data_ptr); /* free the hashish handle */ hi_fini(hi_handle); return 0; }