Hash tables templates, take 2.
Note: this version can handle structures as entries, and it can be used without <su_alloc.h>.
This file contain a hash table template for C. The hash tables are resizeable, and they usually contain pointers to entries. The declaration for template datatypes is instantiated with macro HTABLE2_DECLARE(). The prototypes for hashing functions are instantiated with macro HTABLE2_PROTOS(). The implementation is instantiated with macro HTABLE2_BODIES().
The hash table template is most efficient when the hash value is precalculated and stored in each entry. The hash "function" given to the HTABLE2_BODIES() would then be something like macro
#define HTABLE2_ENTRY_HASH(e) ((e).e_hash_value)
When a entry with new identical hash key is added to the table, it can be either inserted (before any other entry with same key value) or appended.
Example code can be found from <htable_test.c>.
Definition in file htable2.h.
|#define||HTABLE2_BODIES(type, prefix, pr, entrytype,hfun, is_used, reclaim, is_equal, halloc)|
|#define||HTABLE2_DECLARE(sname, prefix, pr, entrytype)|
|#define||HTABLE2_PROTOS(type, prefix, pr, entrytype)|
|typedef unsigned long||hash_value_t|