#include <string.h>
#include <stddef.h>
Go to the source code of this file.
Data Structures | |
struct | UT_hash_bucket |
struct | UT_hash_table |
struct | UT_hash_handle |
Defines | |
#define | uthash_fatal(msg) exit(-1) |
#define | uthash_bkt_malloc(sz) malloc(sz) |
#define | uthash_bkt_free(ptr) free(ptr) |
#define | uthash_tbl_malloc(sz) malloc(sz) |
#define | uthash_tbl_free(ptr) free(ptr) |
#define | uthash_noexpand_fyi(tbl) |
#define | uthash_expand_fyi(tbl) |
#define | HASH_INITIAL_NUM_BUCKETS 32 |
#define | HASH_INITIAL_NUM_BUCKETS_LOG2 5 |
#define | HASH_BKT_CAPACITY_THRESH 10 |
#define | HASH_FIND(hh, head, keyptr, keylen_in, out) |
#define | HASH_ADD(hh, head, fieldname, keylen_in, add) HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add) |
#define | HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add) |
#define | HASH_TO_BKT(hashv, num_bkts, bkt) bkt = ((hashv) & ((num_bkts) - 1)) |
#define | HASH_DELETE(hh, head, delptr) |
#define | HASH_FIND_STR(head, findstr, out) HASH_FIND(hh,head,findstr,strlen(findstr),out) |
#define | HASH_ADD_STR(head, strfield, add) HASH_ADD(hh,head,strfield,strlen(add->strfield),add) |
#define | HASH_FIND_INT(head, findint, out) HASH_FIND(hh,head,findint,sizeof(int),out) |
#define | HASH_ADD_INT(head, intfield, add) HASH_ADD(hh,head,intfield,sizeof(int),add) |
#define | HASH_DEL(head, delptr) HASH_DELETE(hh,head,delptr) |
#define | HASH_FSCK(hh, head) |
#define | HASH_EMIT_KEY(hh, head, keyptr, fieldlen) |
#define | HASH_FCN HASH_JEN |
#define | HASH_BER(key, keylen, num_bkts, hash, bkt, i, j, k) |
#define | HASH_SAX(key, keylen, num_bkts, hash, bkt, i, j, k) |
#define | HASH_FNV(key, keylen, num_bkts, hash, bkt, i, j, k) |
#define | HASH_OAT(key, keylen, num_bkts, hash, bkt, i, j, k) |
#define | HASH_JEN_MIX(a, b, c) |
#define | HASH_JEN(key, keylen, num_bkts, hash, bkt, i, j, k) |
#define | HASH_KEYCMP(a, b, len) memcmp(a,b,len) |
#define | HASH_FIND_IN_BKT(hh, head, keyptr, keylen_in, out) |
#define | HASH_ADD_TO_BKT(hh, head, add) |
#define | HASH_DEL_IN_BKT(hh, head, hh_del) |
#define | HASH_EXPAND_BUCKETS(tbl) |
#define | HASH_SORT(head, cmpfcn) HASH_SRT(hh,head,cmpfcn) |
#define | HASH_SRT(hh, head, cmpfcn) |
#define HASH_ADD | ( | hh, | |||
head, | |||||
fieldname, | |||||
keylen_in, | |||||
add | ) | HASH_ADD_KEYPTR(hh,head,&add->fieldname,keylen_in,add) |
#define HASH_ADD_INT | ( | head, | |||
intfield, | |||||
add | ) | HASH_ADD(hh,head,intfield,sizeof(int),add) |
#define HASH_ADD_KEYPTR | ( | hh, | |||
head, | |||||
keyptr, | |||||
keylen_in, | |||||
add | ) |
#define HASH_ADD_STR | ( | head, | |||
strfield, | |||||
add | ) | HASH_ADD(hh,head,strfield,strlen(add->strfield),add) |
#define HASH_ADD_TO_BKT | ( | hh, | |||
head, | |||||
add | ) |
Value:
head.count++; \ add->hh.hh_next = head.hh_head; \ add->hh.hh_prev = NULL; \ if (head.hh_head) head.hh_head->hh_prev = &add->hh; \ head.hh_head=&add->hh; \ if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \ && add->hh.tbl->noexpand != 1) { \ HASH_EXPAND_BUCKETS(add->hh.tbl) \ }
#define HASH_BER | ( | key, | |||
keylen, | |||||
num_bkts, | |||||
hash, | |||||
bkt, | |||||
i, | |||||
j, | |||||
k | ) |
#define HASH_DEL | ( | head, | |||
delptr | ) | HASH_DELETE(hh,head,delptr) |
#define HASH_DEL_IN_BKT | ( | hh, | |||
head, | |||||
hh_del | ) |
#define HASH_FIND | ( | hh, | |||
head, | |||||
keyptr, | |||||
keylen_in, | |||||
out | ) |
Value:
do { \ out=head; \ if (head) { \ (head)->hh.tbl->key = (char*)(keyptr); \ (head)->hh.tbl->keylen = keylen_in; \ HASH_FCN((head)->hh.tbl->key,(head)->hh.tbl->keylen, \ (head)->hh.tbl->num_buckets, \ (head)->hh.tbl->hash_scratch, (head)->hh.tbl->bkt, \ (head)->hh.tbl->i, (head)->hh.tbl->j,(head)->hh.tbl->k); \ HASH_FIND_IN_BKT(hh, (head)->hh.tbl->buckets[ (head)->hh.tbl->bkt], \ keyptr,keylen_in,out); \ } \ } while (0)
#define HASH_FIND_IN_BKT | ( | hh, | |||
head, | |||||
keyptr, | |||||
keylen_in, | |||||
out | ) |
Value:
out = (head.hh_head) ? (head.hh_head->elmt) : NULL; \ while (out) { \ if (out->hh.keylen == keylen_in) { \ if ((HASH_KEYCMP(out->hh.key,keyptr,keylen_in)) == 0) break; \ } \ out= (out->hh.hh_next) ? (out->hh.hh_next->elmt) : NULL; \ }
#define HASH_FIND_INT | ( | head, | |||
findint, | |||||
out | ) | HASH_FIND(hh,head,findint,sizeof(int),out) |
#define HASH_FIND_STR | ( | head, | |||
findstr, | |||||
out | ) | HASH_FIND(hh,head,findstr,strlen(findstr),out) |
#define HASH_FNV | ( | key, | |||
keylen, | |||||
num_bkts, | |||||
hash, | |||||
bkt, | |||||
i, | |||||
j, | |||||
k | ) |
#define HASH_JEN | ( | key, | |||
keylen, | |||||
num_bkts, | |||||
hash, | |||||
bkt, | |||||
i, | |||||
j, | |||||
k | ) |
#define HASH_JEN_MIX | ( | a, | |||
b, | |||||
c | ) |
Value:
{ \ a -= b; a -= c; a ^= ( c >> 13 ); \ b -= c; b -= a; b ^= ( a << 8 ); \ c -= a; c -= b; c ^= ( b >> 13 ); \ a -= b; a -= c; a ^= ( c >> 12 ); \ b -= c; b -= a; b ^= ( a << 16 ); \ c -= a; c -= b; c ^= ( b >> 5 ); \ a -= b; a -= c; a ^= ( c >> 3 ); \ b -= c; b -= a; b ^= ( a << 10 ); \ c -= a; c -= b; c ^= ( b >> 15 ); \ }
#define HASH_OAT | ( | key, | |||
keylen, | |||||
num_bkts, | |||||
hash, | |||||
bkt, | |||||
i, | |||||
j, | |||||
k | ) |
#define HASH_SAX | ( | key, | |||
keylen, | |||||
num_bkts, | |||||
hash, | |||||
bkt, | |||||
i, | |||||
j, | |||||
k | ) |
#define HASH_SORT | ( | head, | |||
cmpfcn | ) | HASH_SRT(hh,head,cmpfcn) |
#define HASH_TO_BKT | ( | hashv, | |||
num_bkts, | |||||
bkt | ) | bkt = ((hashv) & ((num_bkts) - 1)) |