23 #if defined __cplusplus || (defined __STDC__ && __STDC__) || defined WINDOWS32 24 # if !defined __GLIBC__ || !defined __P 26 # define __P(protos) protos 30 # define __P(protos) () 36 typedef unsigned long (*hash_func_t)
__P((
void const *key));
37 typedef int (*hash_cmp_func_t)
__P((
void const *x,
void const *y));
38 typedef void (*hash_map_func_t)
__P((
void const *item));
39 typedef void (*hash_map_arg_func_t)
__P((
void const *item,
void *arg));
56 typedef int (*qsort_cmp_t)
__P((
void const *,
void const *));
58 void hash_init
__P((
struct hash_table *ht,
unsigned long size,
59 hash_func_t hash_1, hash_func_t hash_2, hash_cmp_func_t hash_cmp));
61 unsigned long cardinality,
unsigned long size));
62 void **hash_find_slot
__P((
struct hash_table *ht,
void const *key));
63 void *hash_find_item
__P((
struct hash_table *ht,
void const *key));
64 void *hash_insert
__P((
struct hash_table *ht,
const void *item));
65 void *hash_insert_at
__P((
struct hash_table *ht,
const void *item,
void const *slot));
66 void *hash_delete
__P((
struct hash_table *ht,
void const *item));
67 void *hash_delete_at
__P((
struct hash_table *ht,
void const *slot));
71 void hash_map
__P((
struct hash_table *ht, hash_map_func_t map));
72 void hash_map_arg
__P((
struct hash_table *ht, hash_map_arg_func_t map,
void *arg));
73 void hash_print_stats
__P((
struct hash_table *ht, FILE *out_FILE));
74 void **hash_dump
__P((
struct hash_table *ht,
void **vector_0, qsort_cmp_t compare));
76 extern unsigned jhash(
unsigned char const *key,
int n);
80 #define HASH_VACANT(item) ((item) == 0 || (void *) (item) == hash_deleted_item) 88 #define STRING_HASH_1(KEY, RESULT) do { \ 89 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 90 (RESULT) += jhash_string(_key_); \ 92 #define return_STRING_HASH_1(KEY) do { \ 93 unsigned long _result_ = 0; \ 94 STRING_HASH_1 ((KEY), _result_); \ 101 #define STRING_HASH_2(KEY, RESULT) do { \ 104 #define return_STRING_HASH_2(KEY) do { \ 105 unsigned long _result_ = 0; \ 106 STRING_HASH_2 ((KEY), _result_); \ 110 #define STRING_COMPARE(X, Y, RESULT) do { \ 111 RESULT = (X) == (Y) ? 0 : strcmp ((X), (Y)); \ 113 #define return_STRING_COMPARE(X, Y) do { \ 114 return (X) == (Y) ? 0 : strcmp ((X), (Y)); \ 118 #define STRING_N_HASH_1(KEY, N, RESULT) do { \ 119 unsigned char const *_key_ = (unsigned char const *) (KEY); \ 120 (RESULT) += jhash(_key_, N); \ 123 #define return_STRING_N_HASH_1(KEY, N) do { \ 124 unsigned long _result_ = 0; \ 125 STRING_N_HASH_1 ((KEY), (N), _result_); \ 132 #define STRING_N_HASH_2(KEY, N, RESULT) do { \ 137 #define return_STRING_N_HASH_2(KEY, N) do { \ 138 unsigned long _result_ = 0; \ 139 STRING_N_HASH_2 ((KEY), (N), _result_); \ 143 #define STRING_N_COMPARE(X, Y, N, RESULT) do { \ 144 RESULT = (X) == (Y) ? 0 : memcmp ((X), (Y), (N)); \ 146 #define return_STRING_N_COMPARE(X, Y, N) do { \ 147 return (X) == (Y) ? 0 : memcmp ((X), (Y), (N)); \ 150 #ifdef HAVE_CASE_INSENSITIVE_FS 154 #define ISTRING_HASH_1(KEY, RESULT) do { \ 155 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ 157 (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0xf)); \ 159 #define return_ISTRING_HASH_1(KEY) do { \ 160 unsigned long _result_ = 0; \ 161 ISTRING_HASH_1 ((KEY), _result_); \ 165 #define ISTRING_HASH_2(KEY, RESULT) do { \ 166 unsigned char const *_key_ = (unsigned char const *) (KEY) - 1; \ 168 (RESULT) += ((isupper (*_key_) ? tolower (*_key_) : *_key_) << (_key_[1] & 0x7)); \ 170 #define return_ISTRING_HASH_2(KEY) do { \ 171 unsigned long _result_ = 0; \ 172 ISTRING_HASH_2 ((KEY), _result_); \ 176 #define ISTRING_COMPARE(X, Y, RESULT) do { \ 177 RESULT = (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \ 179 #define return_ISTRING_COMPARE(X, Y) do { \ 180 return (X) == (Y) ? 0 : strcasecmp ((X), (Y)); \ 185 #define ISTRING_HASH_1(KEY, RESULT) STRING_HASH_1 ((KEY), (RESULT)) 186 #define return_ISTRING_HASH_1(KEY) return_STRING_HASH_1 (KEY) 188 #define ISTRING_HASH_2(KEY, RESULT) STRING_HASH_2 ((KEY), (RESULT)) 189 #define return_ISTRING_HASH_2(KEY) return_STRING_HASH_2 (KEY) 191 #define ISTRING_COMPARE(X, Y, RESULT) STRING_COMPARE ((X), (Y), (RESULT)) 192 #define return_ISTRING_COMPARE(X, Y) return_STRING_COMPARE ((X), (Y)) 198 #define INTEGER_HASH_1(KEY, RESULT) do { \ 199 (RESULT) += ((unsigned long)(KEY)); \ 201 #define return_INTEGER_HASH_1(KEY) do { \ 202 unsigned long _result_ = 0; \ 203 INTEGER_HASH_1 ((KEY), _result_); \ 207 #define INTEGER_HASH_2(KEY, RESULT) do { \ 208 (RESULT) += ~((unsigned long)(KEY)); \ 210 #define return_INTEGER_HASH_2(KEY) do { \ 211 unsigned long _result_ = 0; \ 212 INTEGER_HASH_2 ((KEY), _result_); \ 216 #define INTEGER_COMPARE(X, Y, RESULT) do { \ 219 #define return_INTEGER_COMPARE(X, Y) do { \ 221 INTEGER_COMPARE (X, Y, _result_); \ 227 #define ADDRESS_HASH_1(KEY, RESULT) INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3, (RESULT)) 228 #define ADDRESS_HASH_2(KEY, RESULT) INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3, (RESULT)) 229 #define ADDRESS_COMPARE(X, Y, RESULT) INTEGER_COMPARE ((X), (Y), (RESULT)) 230 #define return_ADDRESS_HASH_1(KEY) return_INTEGER_HASH_1 (((unsigned long)(KEY)) >> 3) 231 #define return_ADDRESS_HASH_2(KEY) return_INTEGER_HASH_2 (((unsigned long)(KEY)) >> 3) 232 #define return_ADDRESS_COMPARE(X, Y) return_INTEGER_COMPARE ((X), (Y)) unsigned long ht_lookups
Definition: hash.h:52
hash_func_t ht_hash_1
Definition: hash.h:44
unsigned long ht_collisions
Definition: hash.h:51
unsigned int ht_rehashes
Definition: hash.h:53
unsigned long ht_empty_slots
Definition: hash.h:50
unsigned jhash_string(unsigned char const *key)
unsigned jhash(unsigned char const *key, int n)
hash_func_t ht_hash_2
Definition: hash.h:45
unsigned long ht_capacity
Definition: hash.h:48
hash_cmp_func_t ht_compare
Definition: hash.h:46
unsigned long ht_fill
Definition: hash.h:49
#define __P(protos)
Definition: hash.h:30
void ** ht_vec
Definition: hash.h:43
unsigned long ht_size
Definition: hash.h:47