diff -r 23bb65cbf7a4 -r 91ac86557290 ucx/map.h --- a/ucx/map.h Fri Feb 24 15:53:50 2012 +0100 +++ b/ucx/map.h Fri May 25 17:39:27 2012 +0200 @@ -12,9 +12,13 @@ extern "C" { #endif -typedef struct UcxMap UcxMap; -typedef struct UcxKey UcxKey; -typedef struct UcxMapElement UcxMapElement; +#define UCX_MAP_FOREACH(type,elm,map,iter) \ + for(type elm;ucx_map_iter_next(&iter,(void*)&elm)==0;) + +typedef struct UcxMap UcxMap; +typedef struct UcxKey UcxKey; +typedef struct UcxMapElement UcxMapElement; +typedef struct UcxMapIterator UcxMapIterator; struct UcxMap { UcxMapElement **map; @@ -33,6 +37,12 @@ UcxKey key; }; +struct UcxMapIterator { + UcxMap *map; + UcxMapElement *cur; + int index; +}; + UcxMap *ucx_map_new(size_t size); void ucx_map_free(UcxMap *map); @@ -49,6 +59,10 @@ int ucx_hash(char *data, size_t len); +UcxMapIterator ucx_map_iterator(UcxMap *map); + +int ucx_map_iter_next(UcxMapIterator *i, void **elm); + #ifdef __cplusplus } #endif