Shark Deng

Interactive Designer @Shanju Design in Shanghai

touched caffe / mxnet / python / wordpress / bootstrap / Arduino / Raspberry Pi / webgl / three.js / PIXI / 3dMax

Email

Github

Uthash

2019-11-12 23:50:38

一)作者及下载地址

http://troydhanson.github.io/uthash/

在下载的包里,作者提供了丰富的样例,非常好!

二)原理

1)三个结构

typedef struct UT_hash_bucket {
    struct UT_hash_handle *hh_head;
    unsigned count;
    unsigned expand_mult;
} UT_hash_bucket;
typedef struct UT_hash_handle {
    struct UT_hash_table *tbl;
    void *prev;
    void *next; 
    struct UT_hash_handle *hh_prev;
    struct UT_hash_handle *hh_next; 
    void *key;
    unsigned keylen;
    unsigned hashv;
} UT_hash_handle;
typedef struct UT_hash_table {
    UT_hash_bucket *buckets;
    unsigned num_buckets, log2_num_buckets;
    unsigned num_items;
    struct UT_hash_handle *tail;
    ptrdiff_t hho;
    unsigned ideal_chain_maxlen;
    unsigned nonideal_items;
    unsigned ineff_expands, no expand;
    uint32_t signature;

    uint32_t bloom_sig;
    uint8_t *bloom_bv;
    uint8_t bloom_nbits;
} UT_hash_table;

二)API

HASH_ADD

HASH_ADD_INT

HASH_ADD_KEYPTR

HASH_ADD_KEYPTR_BYHASHVALUE


HASH_FIND

HASH_FIND_INT


HASH_DEL

 



——By SharkDeng
如果你喜欢我的文章,欢迎红包赞赏

Leave a Reply

Your email address will not be published. Required fields are marked *