00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef __AW_HASH__
00030 #define __AW_HASH__
00031
00041 #include "errors.h"
00042 #include "util.h"
00043
00044
00045
00046
00047 #define AW_HASH_NULL_KEY 0
00048
00049
00050
00051 typedef struct {
00052
00053 u_int32_t key;
00054
00055 void *user_pointer;
00056
00057 u_int32_t n_collisions;
00058
00059 } aw_hash32_entry_t;
00060
00061
00062 typedef struct {
00063
00064 u_int32_t nvalid_entries;
00065
00066 u_int32_t nentries;
00067
00068 u_int32_t modmask;
00069
00070 u_int32_t max_collisions;
00071
00072 aw_hash32_entry_t *entries;
00073
00074 } aw_hash32_t;
00075
00076
00082 aw_hash32_t *aw_hash32_make(u_int32_t nentries);
00083
00089 void aw_hash32_clear(aw_hash32_t *ht);
00090
00096 void aw_hash32_destroy(aw_hash32_t *ht);
00097
00106 int aw_hash32_insert(u_int32_t key, void *user_pointer, aw_hash32_t *ht);
00107
00108
00115 void aw_hash32_delete(u_int32_t key, aw_hash32_t *ht);
00116
00124 void *aw_hash32_fetch(u_int32_t key, const aw_hash32_t *ht);
00125
00134 int32_t aw_hash32_incr(u_int32_t key, int32_t incr, aw_hash32_t *ht);
00135
00136
00144 void aw_hash32_thin(aw_hash32_t *ht, void *user_pointer, u_int32_t (*eval)(void *user_pointer, void *valuer_ptr) );
00145
00153 void aw_hash32_map(aw_hash32_t *ht, void *user_pointer, void (*eval)(void *user_pointer, u_int32_t key, void *valuer_ptr) );
00154
00155
00156
00157 typedef struct {
00158
00159 u_int64_t key;
00160
00161 void *user_pointer;
00162
00163 u_int32_t n_collisions;
00164
00165 } aw_hash64_entry_t;
00166
00167
00168 typedef struct {
00169
00170 u_int32_t nvalid_entries;
00171
00172 u_int32_t nentries;
00173
00174 u_int32_t modmask;
00175
00176 u_int32_t max_collisions;
00177
00178 aw_hash64_entry_t *entries;
00179
00180 } aw_hash64_t;
00181
00187 aw_hash64_t *aw_hash64_make(u_int32_t nentries);
00188
00194 void aw_hash64_clear(aw_hash64_t *ht);
00195
00201 void aw_hash64_destroy(aw_hash64_t *ht);
00202
00211 int aw_hash64_insert(u_int64_t key, void *user_pointer, aw_hash64_t *ht);
00212
00219 void aw_hash64_delete(u_int64_t key, aw_hash64_t *ht);
00220
00228 void *aw_hash64_fetch(u_int64_t key, const aw_hash64_t *ht);
00229
00238 int32_t aw_hash64_incr(u_int64_t key, int32_t incr, aw_hash64_t *ht);
00239
00240
00248 void aw_hash64_thin(aw_hash64_t *ht, void *user_pointer, u_int32_t (*eval)(void *user_pointer, void *valuer_ptr) );
00249
00257 void aw_hash64_map(aw_hash64_t *ht, void *user_pointer, void (*eval)(void *user_pointer, u_int64_t key, void *valuer_ptr) );
00258
00259
00260
00261 typedef struct {
00262
00263 byte_t *key;
00264
00265 void *user_pointer;
00266
00267 u_int32_t n_collisions;
00268
00269 } aw_hashString_entry_t;
00270
00271
00272 typedef struct {
00273
00274 u_int32_t nvalid_entries;
00275
00276 u_int32_t nentries;
00277
00278 u_int32_t modmask;
00279
00280 u_int32_t max_collisions;
00281
00282 aw_hashString_entry_t *entries;
00283
00284 } aw_hashString_t;
00285
00291 aw_hashString_t *aw_hashString_make(u_int32_t nentries);
00292
00298 void aw_hashString_clear(aw_hashString_t *ht);
00299
00305 void aw_hashString_destroy(aw_hashString_t *ht);
00306
00315 int aw_hashString_insert(const byte_t *key, void *user_pointer, aw_hashString_t *ht);
00316
00323 void aw_hashString_delete(const byte_t *key, aw_hashString_t *ht);
00324
00332 void *aw_hashString_fetch(const byte_t *key, const aw_hashString_t *ht);
00333
00334
00342 void aw_hashString_thin(aw_hashString_t *ht, void *user_pointer, u_int32_t (*eval)(void *user_pointer, void *valuer_ptr) );
00343
00351 void aw_hashString_map(aw_hashString_t *ht, void *user_pointer, void (*eval)(void *user_pointer, byte_t *key, void *valuer_ptr) );
00352
00353 #endif