2019-07-28 10:31:56 +08:00
|
|
|
|
#ifndef ACL_BINHASH_INCLUDE_H
|
2014-11-19 00:25:21 +08:00
|
|
|
|
#define ACL_BINHASH_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "acl_define.h"
|
|
|
|
|
#include "acl_hash.h" /* just for ACL_HASH_FN */
|
|
|
|
|
#include "acl_slice.h"
|
|
|
|
|
#include "acl_iterator.h"
|
|
|
|
|
|
|
|
|
|
typedef struct ACL_BINHASH ACL_BINHASH;
|
|
|
|
|
typedef struct ACL_BINHASH_INFO ACL_BINHASH_INFO;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Structure of one hash table.
|
|
|
|
|
*/
|
|
|
|
|
struct ACL_BINHASH {
|
|
|
|
|
int size; /**< length of entries array */
|
|
|
|
|
int used; /**< number of entries in table */
|
|
|
|
|
unsigned int flag; /**< the hash table's properties flag */
|
|
|
|
|
int status; /**< the hash tables' operation status */
|
|
|
|
|
ACL_BINHASH_INFO **data; /**< entries array, auto-resized */
|
|
|
|
|
ACL_SLICE *slice; /**< memory slice */
|
|
|
|
|
ACL_HASH_FN hash_fn; /**< hash function */
|
|
|
|
|
|
|
|
|
|
/* for acl_iterator */
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void *(*iter_head)(ACL_ITER*, struct ACL_BINHASH*);
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void *(*iter_next)(ACL_ITER*, struct ACL_BINHASH*);
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>β<EFBFBD><CEB2><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void *(*iter_tail)(ACL_ITER*, struct ACL_BINHASH*);
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
void *(*iter_prev)(ACL_ITER*, struct ACL_BINHASH*);
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/* ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>ṹ<EFBFBD><E1B9B9><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
ACL_BINHASH_INFO *(*iter_info)(ACL_ITER*, struct ACL_BINHASH*);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Structure of one hash table entry.
|
|
|
|
|
*/
|
|
|
|
|
struct ACL_BINHASH_INFO {
|
|
|
|
|
union {
|
|
|
|
|
void *key;
|
|
|
|
|
const void *c_key;
|
|
|
|
|
} key; /**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>, ֻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>־λΪ
|
|
|
|
|
* ACL_BINHASH_FLAG_KEY_REUSE ʱ<EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD>ռ<EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
2019-07-28 10:31:56 +08:00
|
|
|
|
int key_len; /**< <20><>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
void *value; /**< <20><>ϣ<EFBFBD><CFA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><D3A6><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD> */
|
2014-11-19 00:25:21 +08:00
|
|
|
|
struct ACL_BINHASH_INFO *next; /**< colliding entry */
|
|
|
|
|
struct ACL_BINHASH_INFO *prev; /**< colliding entry */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ACL_BINHASH <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
typedef struct ACL_BINHASH_ITER {
|
|
|
|
|
/* public */
|
|
|
|
|
ACL_BINHASH_INFO *ptr;
|
|
|
|
|
|
|
|
|
|
/* private */
|
|
|
|
|
int i;
|
|
|
|
|
int size;
|
|
|
|
|
ACL_BINHASH_INFO **h;
|
|
|
|
|
} ACL_BINHASH_ITER;
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param size {int} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param flag {unsigned int} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>־λ, ACL_BINHASH_FLAG_xxx
|
|
|
|
|
* @return {ACL_BINHASH*} <EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_BINHASH *acl_binhash_create(int size, unsigned int flag);
|
|
|
|
|
#define ACL_BINHASH_FLAG_KEY_REUSE (1 << 0)
|
|
|
|
|
#define ACL_BINHASH_FLAG_SLICE_RTGC_OFF (1 << 1)
|
|
|
|
|
#define ACL_BINHASH_FLAG_SLICE1 (1 << 2)
|
|
|
|
|
#define ACL_BINHASH_FLAG_SLICE2 (1 << 3)
|
|
|
|
|
#define ACL_BINHASH_FLAG_SLICE3 (1 << 4)
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {const void*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_len {int} key <EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param value {void*} <EFBFBD><EFBFBD>ֵ
|
|
|
|
|
* @return {ACL_BINHASH_INFO*} <EFBFBD>´<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD><EFBFBD>Ŀָ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_BINHASH_INFO *acl_binhash_enter(ACL_BINHASH *table, const void *key, int key_len, void *value);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ӹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>и<EFBFBD><EFBFBD>ݼ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>ö<EFBFBD>Ӧ<EFBFBD>Ĺ<EFBFBD>ϣ<EFBFBD><EFBFBD>Ŀ
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {const void*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_len {int} key <EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ACL_BINHASH_INFO*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>Ŀָ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_BINHASH_INFO *acl_binhash_locate(ACL_BINHASH *table, const void *key, int key_len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ѯij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>ֵ
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {const void*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_len {int} key <EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @return {void*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void *acl_binhash_find(ACL_BINHASH *table, const void *key, int key_len);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* ɾ<EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key {const void*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param key_len {int} key <EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param free_fn {void (*)(void*)} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷŹ<EFBFBD>ϣ<EFBFBD><EFBFBD>ֵ<EFBFBD>ĺ<EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>룬<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><EFBFBD>ͷż<EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int} 0: ok, -1: error
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_binhash_delete(ACL_BINHASH *table, const void *key, int key_len, void (*free_fn) (void *));
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ͷŹ<EFBFBD>ϣ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param free_fn {void (*)(void*)} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ô˺<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷŹ<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD>ֵ
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_binhash_free(ACL_BINHASH *table, void (*free_fn) (void *));
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>еļ<EFBFBD>ֵ
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param walk_fn {void (*)(ACL_BINHASH_INFO*, void*)} <EFBFBD>ڱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ÿ<EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>ʱ<EFBFBD>Ļص<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param arg {void*} <EFBFBD>û<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵIJ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> walk_fn <EFBFBD>д<EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API void acl_binhash_walk(ACL_BINHASH *table, void (*walk_fn) (ACL_BINHASH_INFO *, void *), void *arg);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>г<EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {ACL_BINHASH_INFO*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵ<EFBFBD>ACL_BINHASH_INFO<EFBFBD><EFBFBD><EFBFBD><EFBFBD>,
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>Ϊ NULL
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API ACL_BINHASH_INFO **acl_binhash_list(ACL_BINHASH *table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ù<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return {int} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_binhash_errno(ACL_BINHASH *table);
|
|
|
|
|
#define ACL_BINHASH_STAT_OK 0
|
|
|
|
|
#define ACL_BINHASH_STAT_INVAL 1
|
|
|
|
|
#define ACL_BINHASH_STAT_DUPLEX_KEY 2
|
|
|
|
|
#define ACL_BINHASH_STAT_NO_KEY 3
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>ع<EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
|
|
|
|
|
* @param table <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
|
|
|
|
* @return <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD><EFBFBD><EFBFBD>С
|
2014-11-19 00:25:21 +08:00
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_binhash_size(const ACL_BINHASH *table);
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param table {ACL_BINHASH*} <EFBFBD><EFBFBD>ϣ<EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD>
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @return {int}
|
|
|
|
|
*/
|
|
|
|
|
ACL_API int acl_binhash_used(ACL_BINHASH *table);
|
|
|
|
|
|
|
|
|
|
ACL_API ACL_BINHASH_INFO **acl_binhash_data(ACL_BINHASH *table);
|
|
|
|
|
ACL_API const ACL_BINHASH_INFO *acl_binhash_iter_head(ACL_BINHASH *table, ACL_BINHASH_ITER *iter);
|
|
|
|
|
ACL_API const ACL_BINHASH_INFO *acl_binhash_iter_next(ACL_BINHASH_ITER *iter);
|
|
|
|
|
ACL_API const ACL_BINHASH_INFO *acl_binhash_iter_tail(ACL_BINHASH *table, ACL_BINHASH_ITER *iter);
|
|
|
|
|
ACL_API const ACL_BINHASH_INFO *acl_binhash_iter_prev(ACL_BINHASH_ITER *iter);
|
|
|
|
|
|
2019-07-28 10:31:56 +08:00
|
|
|
|
/*-------------------- һЩ<D2BB><D0A9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĺ<DDB5><C4BA><EFBFBD><EFBFBD><EFBFBD> --------------------------------*/
|
2014-11-19 00:25:21 +08:00
|
|
|
|
|
|
|
|
|
#define ACL_BINHASH_ITER_KEY(iter) ((iter).ptr->key.c_key)
|
|
|
|
|
#define acl_binhash_iter_key ACL_BINHASH_ITER_KEY
|
|
|
|
|
|
|
|
|
|
#define ACL_BINHASH_ITER_VALUE(iter) ((iter).ptr->value)
|
|
|
|
|
#define acl_binhash_iter_value ACL_BINHASH_ITER_VALUE
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ACL_BINHASH
|
2014-11-19 00:25:21 +08:00
|
|
|
|
* @param iter {ACL_BINHASH_ITER}
|
|
|
|
|
* @param table_ptr {ACL_BINHASH *}
|
|
|
|
|
* @example:
|
|
|
|
|
void test()
|
|
|
|
|
{
|
|
|
|
|
ACL_BINHASH *table = acl_binhash_create(10, 0);
|
|
|
|
|
ACL_BINHASH_ITER iter;
|
|
|
|
|
char *value, key[32];
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 100; i++) {
|
|
|
|
|
value = (char*) acl_mystrdup("value");
|
|
|
|
|
snprintf(key, sizeof(key), "key:%d", i);
|
|
|
|
|
(void) acl_binhash_enter(table, key, strlen(key), value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acl_binhash_foreach(iter, table) {
|
|
|
|
|
printf("%s=%s\n", iter.ptr->key.c_key, iter.ptr->value);
|
|
|
|
|
if (i == 50)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
acl_binhash_free(table, acl_myfree_fn);
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
#if 0
|
|
|
|
|
#define ACL_BINHASH_FOREACH(iter, table_ptr) \
|
|
|
|
|
if (table_ptr) \
|
|
|
|
|
for((iter).size = acl_binhash_size((table_ptr)), (iter).i = 0, \
|
|
|
|
|
(iter).h = acl_binhash_data((table_ptr)); (iter).i < (iter).size; (iter).i++) \
|
|
|
|
|
for ((iter).ptr = *(iter).h++; (iter).ptr; (iter).ptr = (iter).ptr->next)
|
|
|
|
|
#define ACL_BINHASH_FOREACH_REVERSE(iter, table_ptr) \
|
|
|
|
|
if (table_ptr) \
|
|
|
|
|
for((iter).size = acl_binhash_size((table_ptr)), (iter).i = (iter).size - 1, \
|
|
|
|
|
(iter).h = acl_binhash_data((table_ptr)) + (iter).i; (iter).i >= 0; (iter).i--) \
|
|
|
|
|
for ((iter).ptr = *(iter).h--; (iter).ptr; (iter).ptr = (iter).ptr->next)
|
|
|
|
|
#else
|
|
|
|
|
#define ACL_BINHASH_FOREACH(iter, table_ptr) \
|
|
|
|
|
if (table_ptr) \
|
|
|
|
|
for((void) acl_binhash_iter_head((table_ptr), &iter); \
|
|
|
|
|
(iter).ptr; \
|
|
|
|
|
(void) acl_binhash_iter_next(&iter))
|
|
|
|
|
#define ACL_BINHASH_FOREACH_REVERSE(iter, table_ptr) \
|
|
|
|
|
if (table_ptr) \
|
|
|
|
|
for((void) acl_binhash_iter_tail((table_ptr), &iter); \
|
|
|
|
|
(iter).ptr; \
|
|
|
|
|
(void) acl_binhash_iter_prev(&iter))
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define acl_binhash_foreach ACL_BINHASH_FOREACH
|
|
|
|
|
#define acl_binhash_foreach_reverse ACL_BINHASH_FOREACH_REVERSE
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|