11 #ifndef __FN_FINALIZE_T_DEFINED
12 typedef int (*fn_finalize_t)(void**);
13 #define __FN_FINALIZE_T_DEFINED
18 * pointer to a compare key function.
19 * the function takes two items to compare and returns true if they are equal.
21 #ifndef __FN_CMP_KEY_T_DEFINED
22 typedef int (*fn_cmp_key_t)(const void*, const void*);
23 #define __FN_CMP_KEY_T_DEFINED
27 * pointer to a hash function.
28 * the function take the value to compute the hash value that it returns.
30 #ifndef __FN_HFUNC_T_DEFINED
31 typedef unsigned int (*fn_hfunc_t)(const void*);
32 #define __FN_HFUNC_T_DEFINED
35 typedef struct s_hassoc
37 struct s_hassoc* next;
40 }s_hassoc_t,* hassoc_t;
42 typedef struct s_htable
44 hassoc_t* content; /* the hache table content */
45 int size; /* the size of the hash table */
46 allocator_t allocator; /* the allocator used to allocate the associations */
47 fn_hfunc_t fn_hfunc; /* a pointer to the hash function to use */
48 fn_cmp_key_t fn_cmp_key; /* a pointer to the function used to fn_cmp_key the key */
49 fn_finalize_t fn_finalize;
50 }s_htable_t,* htable_t;
58 int block_capacity, /* the block capacity of the blocks of the allocator used by the htable */
59 int size, /* the size of the table size */
60 fn_hfunc_t fn_hfunc, /* the pointer to the function to use */
61 fn_cmp_key_t fn_cmp_key, /* the pointer to the function used to fn_cmp_key the keys of the assocs */
62 fn_finalize_t fn_finalize /* the pointer to the function used to destroy the values of the assocs */
66 htable_set(htable_t htable, const void* key, const void* val);
69 htable_lookup(htable_t htable, const void* key);
72 htable_remove(htable_t htable, const void* key);
75 htable_erase(htable_t htable, const void* key);
78 htable_free(htable_t* htableptr);
81 htable_clear(htable_t htable);
84 htable_get_size(htable_t htable);
87 htable_is_empty(htable_t htable);
90 htable_is_autodelete(htable_t htable);
96 #endif /* !__HTABLE */