1.1 --- a/ucx/map.h Fri Feb 24 15:53:50 2012 +0100 1.2 +++ b/ucx/map.h Fri May 25 17:39:27 2012 +0200 1.3 @@ -12,9 +12,13 @@ 1.4 extern "C" { 1.5 #endif 1.6 1.7 -typedef struct UcxMap UcxMap; 1.8 -typedef struct UcxKey UcxKey; 1.9 -typedef struct UcxMapElement UcxMapElement; 1.10 +#define UCX_MAP_FOREACH(type,elm,map,iter) \ 1.11 + for(type elm;ucx_map_iter_next(&iter,(void*)&elm)==0;) 1.12 + 1.13 +typedef struct UcxMap UcxMap; 1.14 +typedef struct UcxKey UcxKey; 1.15 +typedef struct UcxMapElement UcxMapElement; 1.16 +typedef struct UcxMapIterator UcxMapIterator; 1.17 1.18 struct UcxMap { 1.19 UcxMapElement **map; 1.20 @@ -33,6 +37,12 @@ 1.21 UcxKey key; 1.22 }; 1.23 1.24 +struct UcxMapIterator { 1.25 + UcxMap *map; 1.26 + UcxMapElement *cur; 1.27 + int index; 1.28 +}; 1.29 + 1.30 1.31 UcxMap *ucx_map_new(size_t size); 1.32 void ucx_map_free(UcxMap *map); 1.33 @@ -49,6 +59,10 @@ 1.34 1.35 int ucx_hash(char *data, size_t len); 1.36 1.37 +UcxMapIterator ucx_map_iterator(UcxMap *map); 1.38 + 1.39 +int ucx_map_iter_next(UcxMapIterator *i, void **elm); 1.40 + 1.41 #ifdef __cplusplus 1.42 } 1.43 #endif