- 宏定义说明
- define DECLTYPE(x)
- define HASH_FSCK(hh, head)
- define HASH_FCN
- define HASH_BLOOM_ADD(tbl, hashv)
- define HASH_MAKE_TABLE(hh, head)
- define NULL
- define HASH_ADD_TO_BKT(head, addhh)
- define ELMT_FROM_HH(tbl, hhp)
- define HASH_EMIT_KEY(hh, head, keyptr, fieldlen)
- define HASH_EXPAND_BUCKETS(tbl)
- define HASH_BKT_CAPACITY_THRESH
- define NULL
- define uthash_free(ptr, sz)
- define HASH_BLOOM_FREE(tbl)
- define NULL
- define HASH_FCN
- define HASH_BLOOM_TEST(tbl, hashv)
- define NULL
- define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, out)
- define DECLTYPE_ASSIGN(dst, src)
- define NULL
- define HASH_KEYCMP(a, b, len)
- define ELMT_FROM_HH(tbl, hhp)
- define NULL
- define DECLTYPE(x)
- define HASH_INITIAL_NUM_BUCKETS
- define HASH_SIGNATURE
- define HASH_INITIAL_NUM_BUCKETS_LOG2
- define uthash_malloc(sz)
- define HASH_BLOOM_MAKE(tbl)
- define uthash_fatal(msg)
- define HASH_BLOOM_BYTELEN
- define HASH_DELETE(hh, head, delptr)
- define NULL
- define HASH_ADD(hh, head, fieldname, keylen_in, add)
- define HASH_FIND(hh, head, keyptr, keylen, out)
cocos2d-x 3.0 |
)
- 文件列表 - 文件成员
全部) 类) 命名空间) 文件) 函数) 变量) 类型定义) 枚举) 枚举值) 属性) 友元) 宏定义) 组) 页)
uthash.h 文件参考
#include
#include
#include
#include
## 类 | |
struct | UT_hash_bucket |
struct | UT_hash_table |
struct | UT_hash_handle |
## 宏定义 | |
#define | DECLTYPE(x) (__typeof(x)) |
#define | DECLTYPE_ASSIGN(dst, src) |
#define | UTHASH_VERSION 1.9.8 |
#define | uthash_fatal(msg) exit(-1) / fatal error (out of memory,etc) / |
#define | uthash_malloc(sz) malloc(sz) / malloc fcn / |
#define | uthash_free(ptr, sz) free(ptr) / free fcn / |
#define | uthash_noexpand_fyi(tbl) / can be defined to log noexpand / |
#define | uthash_expand_fyi(tbl) / can be defined to log expands / |
#define | HASH_INITIAL_NUM_BUCKETS 32 / initial number of buckets / |
#define | HASH_INITIAL_NUM_BUCKETS_LOG2 5 / lg2 of initial number of buckets / |
#define | HASH_BKT_CAPACITY_THRESH 10 / expand when bucket count reaches / |
#define | ELMT_FROM_HH(tbl, hhp) ((void)(((char)(hhp)) - ((tbl)->hho))) |
#define | HASH_FIND(hh, head, keyptr, keylen, out) |
#define | HASH_BLOOM_MAKE(tbl) |
#define | HASH_BLOOM_FREE(tbl) |
#define | HASH_BLOOM_ADD(tbl, hashv) |
#define | HASH_BLOOM_TEST(tbl, hashv) (1) |
#define | HASH_BLOOM_BYTELEN 0 |
#define | HASH_MAKE_TABLE(hh, head) |
#define | HASH_ADD(hh, head, fieldname, keylen_in, add) HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add) |
#define | HASH_REPLACE(hh, head, fieldname, keylen_in, add, replaced) |
#define | HASH_ADD_KEYPTR(hh, head, keyptr, keylen_in, add) |
#define | HASH_TO_BKT(hashv, num_bkts, bkt) |
#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_REPLACE_STR(head, strfield, add, replaced) HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced) |
#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_REPLACE_INT(head, intfield, add, replaced) HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) |
#define | HASH_FIND_PTR(head, findptr, out) HASH_FIND(hh,head,findptr,sizeof(void ),out) |
#define | HASH_ADD_PTR(head, ptrfield, add) HASH_ADD(hh,head,ptrfield,sizeof(void ),add) |
#define | HASH_REPLACE_PTR(head, ptrfield, add) HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) |
#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, hashv, bkt) |
#define | HASH_SAX(key, keylen, num_bkts, hashv, bkt) |
#define | HASH_FNV(key, keylen, num_bkts, hashv, bkt) |
#define | HASH_OAT(key, keylen, num_bkts, hashv, bkt) |
#define | HASH_JEN_MIX(a, b, c) |
#define | HASH_JEN(key, keylen, num_bkts, hashv, bkt) |
#define | get16bits(d) |
#define | HASH_SFH(key, keylen, num_bkts, hashv, bkt) |
#define | HASH_KEYCMP(a, b, len) memcmp(a,b,len) |
#define | HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, out) |
#define | HASH_ADD_TO_BKT(head, addhh) |
#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_SELECT(hh_dst, dst, hh_src, src, cond) |
#define | HASH_CLEAR(hh, head) |
#define | HASH_OVERHEAD(hh, head) |
#define | HASH_ITER(hh, head, el, tmp) |
#define | HASH_COUNT(head) HASH_CNT(hh,head) |
#define | HASH_CNT(hh, head) ((head)?((head)->hh.tbl->num_items):0) |
#define | HASH_SIGNATURE 0xa0111fe1 |
#define | HASH_BLOOM_SIGNATURE 0xb12220f2 |
宏定义说明
#define DECLTYPE | ( | x | ) | (__typeof(x)) |
#define DECLTYPE_ASSIGN | ( | dst, | |
src | |||
) |
值:
do { \
(dst) = DECLTYPE(dst)(src); \
} while(0)
define DECLTYPE(x)
Definition: uthash.h:43
#define ELMT_FROM_HH | ( | tbl, | |
hhp | |||
) | ((void)(((char)(hhp)) - ((tbl)->hho))) |
#define get16bits | ( | d | ) |
值:
((((uint32_t)(((const uint8_t *)(d))[1])) << 8) \
+(uint32_t)(((const uint8_t *)(d))[0]) )
unsigned char uint8_t
Definition: stdint.h:81
unsigned int uint32_t
Definition: stdint.h:83
#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 | |||
) |
值:
do { \
unsigned _ha_bkt; \
(add)->hh.next = NULL; \
(add)->hh.key = (char*)keyptr; \
(add)->hh.keylen = (unsigned)keylen_in; \
if (!(head)) { \
head = (add); \
(head)->hh.prev = NULL; \
HASH_MAKE_TABLE(hh,head); \
} else { \
(head)->hh.tbl->tail->next = (add); \
(add)->hh.prev = ELMT_FROM_HH((head)->hh.tbl, (head)->hh.tbl->tail); \
(head)->hh.tbl->tail = &((add)->hh); \
} \
(head)->hh.tbl->num_items++; \
(add)->hh.tbl = (head)->hh.tbl; \
HASH_FCN(keyptr,keylen_in, (head)->hh.tbl->num_buckets, \
(add)->hh.hashv, _ha_bkt); \
HASH_ADD_TO_BKT((head)->hh.tbl->buckets[_ha_bkt],&(add)->hh); \
HASH_BLOOM_ADD((head)->hh.tbl,(add)->hh.hashv); \
HASH_EMIT_KEY(hh,head,keyptr,keylen_in); \
HASH_FSCK(hh,head); \
} while(0)
define HASH_FSCK(hh, head)
Definition: uthash.h:330
define HASH_FCN
Definition: uthash.h:351
define HASH_BLOOM_ADD(tbl, hashv)
Definition: uthash.h:136
define HASH_MAKE_TABLE(hh, head)
Definition: uthash.h:141
define NULL
Definition: CCPlatformDefine.h:61
define HASH_ADD_TO_BKT(head, addhh)
Definition: uthash.h:611
define ELMT_FROM_HH(tbl, hhp)
Definition: uthash.h:92
define HASH_EMIT_KEY(hh, head, keyptr, fieldlen)
Definition: uthash.h:344
#define HASH_ADD_PTR | ( | head, | |
ptrfield, | |||
add | |||
) | HASH_ADD(hh,head,ptrfield,sizeof(void *),add) |
#define HASH_ADD_STR | ( | head, | |
strfield, | |||
add | |||
) | HASH_ADD(hh,head,strfield,strlen(add->strfield),add) |
#define HASH_ADD_TO_BKT | ( | head, | |
addhh | |||
) |
值:
do { \
head.count++; \
(addhh)->hh_next = head.hh_head; \
(addhh)->hh_prev = NULL; \
if (head.hh_head) { (head).hh_head->hh_prev = (addhh); } \
(head).hh_head=addhh; \
if (head.count >= ((head.expand_mult+1) * HASH_BKT_CAPACITY_THRESH) \
&& (addhh)->tbl->noexpand != 1) { \
HASH_EXPAND_BUCKETS((addhh)->tbl); \
} \
} while(0)
define HASH_EXPAND_BUCKETS(tbl)
Definition: uthash.h:666
define HASH_BKT_CAPACITY_THRESH
Definition: uthash.h:89
define NULL
Definition: CCPlatformDefine.h:61
#define HASH_BER | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
值:
do { \
unsigned _hb_keylen=keylen; \
char _hb_key=(char)(key); \
(hashv) = 0; \
while (_hb_keylen—) { (hashv) = ((hashv) 33) + _hb_key++; } \
bkt = (hashv) & (num_bkts-1); \
} while (0)
#define HASH_BKT_CAPACITY_THRESH 10 / expand when bucket count reaches / |
#define HASH_BLOOM_ADD | ( | tbl, | |
hashv | |||
) |
#define HASH_BLOOM_BYTELEN 0 |
#define HASH_BLOOM_FREE | ( | tbl | ) |
#define HASH_BLOOM_MAKE | ( | tbl | ) |
#define HASH_BLOOM_SIGNATURE 0xb12220f2 |
#define HASH_BLOOM_TEST | ( | tbl, | |
hashv | |||
) | (1) |
#define HASH_CLEAR | ( | hh, | |
head | |||
) |
值:
do { \
if (head) { \
uthash_free((head)->hh.tbl->buckets, \
(head)->hh.tbl->num_buckets*sizeof(struct UT_hash_bucket)); \
HASH_BLOOM_FREE((head)->hh.tbl); \
uthash_free((head)->hh.tbl, sizeof(UT_hash_table)); \
(head)=NULL; \
} \
} while(0)
define uthash_free(ptr, sz)
Definition: uthash.h:76
define HASH_BLOOM_FREE(tbl)
Definition: uthash.h:135
Definition: uthash.h:896
define NULL
Definition: CCPlatformDefine.h:61
Definition: uthash.h:872
#define HASH_CNT | ( | hh, | |
head | |||
) | ((head)?((head)->hh.tbl->num_items):0) |
#define HASH_COUNT | ( | head | ) | HASH_CNT(hh,head) |
#define HASH_DEL | ( | head, | |
delptr | |||
) | HASH_DELETE(hh,head,delptr) |
#define HASH_DEL_IN_BKT | ( | hh, | |
head, | |||
hh_del | |||
) |
值:
(head).count—; \
if ((head).hh_head == hh_del) { \
(head).hh_head = hh_del->hh_next; \
} \
if (hh_del->hh_prev) { \
hh_del->hh_prev->hh_next = hh_del->hh_next; \
} \
if (hh_del->hh_next) { \
hh_del->hh_next->hh_prev = hh_del->hh_prev; \
}
#define HASH_DELETE | ( | hh, | |
head, | |||
delptr | |||
) |
#define HASH_EMIT_KEY | ( | hh, | |
head, | |||
keyptr, | |||
fieldlen | |||
) |
#define HASH_EXPAND_BUCKETS | ( | tbl | ) |
#define HASH_FCN HASH_JEN |
#define HASH_FIND | ( | hh, | |
head, | |||
keyptr, | |||
keylen, | |||
out | |||
) |
值:
do { \
unsigned _hf_bkt,_hf_hashv; \
out=NULL; \
if (head) { \
HASH_FCN(keyptr,keylen, (head)->hh.tbl->num_buckets, _hf_hashv, _hf_bkt); \
if (HASH_BLOOM_TEST((head)->hh.tbl, _hf_hashv)) { \
HASH_FIND_IN_BKT((head)->hh.tbl, hh, (head)->hh.tbl->buckets[ _hf_bkt ], \
keyptr,keylen,out); \
} \
} \
} while (0)
define HASH_FCN
Definition: uthash.h:351
define HASH_BLOOM_TEST(tbl, hashv)
Definition: uthash.h:137
define NULL
Definition: CCPlatformDefine.h:61
define HASH_FIND_IN_BKT(tbl, hh, head, keyptr, keylen_in, out)
Definition: uthash.h:597
#define HASH_FIND_IN_BKT | ( | tbl, | |
hh, | |||
head, | |||
keyptr, | |||
keylen_in, | |||
out | |||
) |
值:
do { \
if (head.hh_head) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,head.hh_head)); \
else out=NULL; \
while (out) { \
if ((out)->hh.keylen == keylen_in) { \
if ((HASH_KEYCMP((out)->hh.key,keyptr,keylen_in)) == 0) break; \
} \
if ((out)->hh.hh_next) DECLTYPE_ASSIGN(out,ELMT_FROM_HH(tbl,(out)->hh.hh_next)); \
else out = NULL; \
} \
} while(0)
define DECLTYPE_ASSIGN(dst, src)
Definition: uthash.h:53
define NULL
Definition: CCPlatformDefine.h:61
define HASH_KEYCMP(a, b, len)
Definition: uthash.h:594
define ELMT_FROM_HH(tbl, hhp)
Definition: uthash.h:92
#define HASH_FIND_INT | ( | head, | |
findint, | |||
out | |||
) | HASH_FIND(hh,head,findint,sizeof(int),out) |
#define HASH_FIND_PTR | ( | head, | |
findptr, | |||
out | |||
) | HASH_FIND(hh,head,findptr,sizeof(void *),out) |
#define HASH_FIND_STR | ( | head, | |
findstr, | |||
out | |||
) | HASH_FIND(hh,head,findstr,strlen(findstr),out) |
#define HASH_FNV | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
值:
do { \
unsigned _fn_i; \
char _hf_key=(char)(key); \
hashv = 2166136261UL; \
for(_fn_i=0; _fn_i < keylen; _fn_i++) \
hashv = (hashv * 16777619) ^ _hf_key[_fn_i]; \
bkt = hashv & (num_bkts-1); \
} while(0)
#define HASH_FSCK | ( | hh, | |
head | |||
) |
#define HASH_INITIAL_NUM_BUCKETS 32 / initial number of buckets / |
#define HASH_INITIAL_NUM_BUCKETS_LOG2 5 / lg2 of initial number of buckets / |
#define HASH_ITER | ( | hh, | |
head, | |||
el, | |||
tmp | |||
) |
值:
for((el)=(head),(tmp)=DECLTYPE(el)((head)?(head)->hh.next:NULL); \
el; (el)=(tmp),(tmp)=DECLTYPE(el)((tmp)?(tmp)->hh.next:NULL))
define NULL
Definition: CCPlatformDefine.h:61
define DECLTYPE(x)
Definition: uthash.h:43
#define HASH_JEN | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
#define HASH_JEN_MIX | ( | a, | |
b, | |||
c | |||
) |
值:
do { \
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 ); \
} while (0)
#define HASH_KEYCMP | ( | a, | |
b, | |||
len | |||
) | memcmp(a,b,len) |
#define HASH_MAKE_TABLE | ( | hh, | |
head | |||
) |
值:
do { \
(head)->hh.tbl = (UT_hash_table*)uthash_malloc( \
sizeof(UT_hash_table)); \
if (!((head)->hh.tbl)) { uthash_fatal( "out of memory"); } \
memset((head)->hh.tbl, 0, sizeof(UT_hash_table)); \
(head)->hh.tbl->tail = &((head)->hh); \
(head)->hh.tbl->num_buckets = HASH_INITIAL_NUM_BUCKETS; \
(head)->hh.tbl->log2_num_buckets = HASH_INITIAL_NUM_BUCKETS_LOG2; \
(head)->hh.tbl->hho = (char)(&(head)->hh) - (char)(head); \
(head)->hh.tbl->buckets = (UT_hash_bucket*)uthash_malloc( \
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
if (! (head)->hh.tbl->buckets) { uthash_fatal( "out of memory"); } \
memset((head)->hh.tbl->buckets, 0, \
HASH_INITIAL_NUM_BUCKETS*sizeof(struct UT_hash_bucket)); \
HASH_BLOOM_MAKE((head)->hh.tbl); \
(head)->hh.tbl->signature = HASH_SIGNATURE; \
} while(0)
define HASH_INITIAL_NUM_BUCKETS
Definition: uthash.h:87
define HASH_SIGNATURE
Definition: uthash.h:893
define HASH_INITIAL_NUM_BUCKETS_LOG2
Definition: uthash.h:88
define uthash_malloc(sz)
Definition: uthash.h:73
define HASH_BLOOM_MAKE(tbl)
Definition: uthash.h:134
Definition: uthash.h:896
define uthash_fatal(msg)
Definition: uthash.h:70
Definition: uthash.h:872
#define HASH_OAT | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
值:
do { \
unsigned _ho_i; \
char _ho_key=(char)(key); \
hashv = 0; \
for(_ho_i=0; _ho_i < keylen; _ho_i++) { \
hashv += _ho_key[_ho_i]; \
hashv += (hashv << 10); \
hashv ^= (hashv >> 6); \
} \
hashv += (hashv << 3); \
hashv ^= (hashv >> 11); \
hashv += (hashv << 15); \
bkt = hashv & (num_bkts-1); \
} while(0)
#define HASH_OVERHEAD | ( | hh, | |
head | |||
) |
值:
(size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
(sizeof(UT_hash_table)) + \
Definition: uthash.h:896
define HASH_BLOOM_BYTELEN
Definition: uthash.h:138
Definition: uthash.h:872
Definition: uthash.h:929
#define HASH_REPLACE | ( | hh, | |
head, | |||
fieldname, | |||
keylen_in, | |||
add, | |||
replaced | |||
) |
值:
do { \
HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \
HASH_DELETE(hh,head,replaced); \
}; \
HASH_ADD(hh,head,fieldname,keylen_in,add); \
} while(0)
define HASH_DELETE(hh, head, delptr)
Definition: uthash.h:215
define NULL
Definition: CCPlatformDefine.h:61
define HASH_ADD(hh, head, fieldname, keylen_in, add)
Definition: uthash.h:160
define HASH_FIND(hh, head, keyptr, keylen, out)
Definition: uthash.h:94
#define HASH_REPLACE_INT | ( | head, | |
intfield, | |||
add, | |||
replaced | |||
) | HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced) |
#define HASH_REPLACE_PTR | ( | head, | |
ptrfield, | |||
add | |||
) | HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced) |
#define HASH_REPLACE_STR | ( | head, | |
strfield, | |||
add, | |||
replaced | |||
) | HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced) |
#define HASH_SAX | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
值:
do { \
unsigned _sx_i; \
char _hs_key=(char)(key); \
hashv = 0; \
for(_sx_i=0; _sx_i < keylen; _sx_i++) \
hashv ^= (hashv << 5) + (hashv >> 2) + _hs_key[_sx_i]; \
bkt = hashv & (num_bkts-1); \
} while (0)
#define HASH_SELECT | ( | hh_dst, | |
dst, | |||
hh_src, | |||
src, | |||
cond | |||
) |
#define HASH_SFH | ( | key, | |
keylen, | |||
num_bkts, | |||
hashv, | |||
bkt | |||
) |
#define HASH_SIGNATURE 0xa0111fe1 |
#define HASH_SORT | ( | head, | |
cmpfcn | |||
) | HASH_SRT(hh,head,cmpfcn) |
#define HASH_SRT | ( | hh, | |
head, | |||
cmpfcn | |||
) |
#define HASH_TO_BKT | ( | hashv, | |
num_bkts, | |||
bkt | |||
) |
值:
do { \
bkt = ((hashv) & ((num_bkts) - 1)); \
} while(0)
#define uthash_expand_fyi | ( | tbl | ) | / can be defined to log expands / |
#define uthash_fatal | ( | msg | ) | exit(-1) / fatal error (out of memory,etc) / |
#define uthash_free | ( | ptr, | |
sz | |||
) | free(ptr) / free fcn / |
#define uthash_malloc | ( | sz | ) | malloc(sz) / malloc fcn / |
#define uthash_noexpand_fyi | ( | tbl | ) | / can be defined to log noexpand / |
#define UTHASH_VERSION 1.9.8 |