2014-11-19 00:06:40 +08:00
|
|
|
|
#ifndef ACL_ITERATOR_INCLUDE_H
|
|
|
|
|
#define ACL_ITERATOR_INCLUDE_H
|
|
|
|
|
|
|
|
|
|
typedef struct ACL_ITER ACL_ITER;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ACL <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݽṹ<EFBFBD>õ<EFBFBD>ͨ<EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
struct ACL_ITER {
|
|
|
|
|
void *ptr; /**< <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
void *data; /**< <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8> */
|
|
|
|
|
int dlen; /**< <20>û<EFBFBD><C3BB><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>, ʵ<><CAB5><EFBFBD>߿<EFBFBD><DFBF><EFBFBD><EFBFBD>ô<EFBFBD>ֵҲ<D6B5>ɲ<EFBFBD><C9B2><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
const char *key; /**< <20><>Ϊ<EFBFBD><CEAA>ϣ<EFBFBD><CFA3><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>, <20><>Ϊ<EFBFBD><CEAA>ϣ<EFBFBD><CFA3>ֵ<EFBFBD><D6B5>ַ */
|
|
|
|
|
int klen; /**< <20><>ΪACL_BINHASH<53><48><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int i; /**< <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
int size; /**< <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD> */
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param iter {ACL_ITER}
|
|
|
|
|
* @param container {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @examples: samples/iterator/
|
|
|
|
|
*/
|
|
|
|
|
#define ACL_FOREACH(iter, container) \
|
|
|
|
|
for ((container)->iter_head(&(iter), (container)); \
|
|
|
|
|
(iter).ptr; \
|
|
|
|
|
(container)->iter_next(&(iter), (container)))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><EFBFBD>
|
|
|
|
|
* @param iter {ACL_ITER}
|
|
|
|
|
* @param container {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
* @examples: samples/iterator/
|
|
|
|
|
*/
|
|
|
|
|
#define ACL_FOREACH_REVERSE(iter, container) \
|
|
|
|
|
for ((container)->iter_tail(&(iter), (container)); \
|
|
|
|
|
(iter).ptr; \
|
|
|
|
|
(container)->iter_prev(&(iter), (container)))
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD>Ա<EFBFBD>ṹ<EFBFBD><EFBFBD><EFBFBD>Ͷ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param iter {ACL_ITER}
|
|
|
|
|
* @param container {void*} <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
*/
|
|
|
|
|
#define ACL_ITER_INFO(iter, container) \
|
|
|
|
|
(container)->iter_info(&(iter), (container))
|
|
|
|
|
|
|
|
|
|
#define acl_foreach_reverse ACL_FOREACH_REVERSE
|
|
|
|
|
#define acl_foreach ACL_FOREACH
|
|
|
|
|
#define acl_iter_info ACL_ITER_INFO
|
|
|
|
|
|
|
|
|
|
#endif
|