1.1 --- a/ucx/map.c Fri Feb 24 15:53:50 2012 +0100 1.2 +++ b/ucx/map.c Fri May 25 17:39:27 2012 +0200 1.3 @@ -148,3 +148,41 @@ 1.4 1.5 return h; 1.6 } 1.7 + 1.8 +UcxMapIterator ucx_map_iterator(UcxMap *map) { 1.9 + UcxMapIterator i; 1.10 + i.map = map; 1.11 + i.cur = NULL; 1.12 + i.index = 0; 1.13 + return i; 1.14 +} 1.15 + 1.16 +int ucx_map_iter_next(UcxMapIterator *i, void **elm) { 1.17 + UcxMapElement *e = i->cur; 1.18 + 1.19 + if(e == NULL) { 1.20 + e = i->map->map[0]; 1.21 + } else { 1.22 + e = e->next; 1.23 + } 1.24 + 1.25 + while(i->index < i->map->size) { 1.26 + if(e != NULL) { 1.27 + if(e->data != NULL) { 1.28 + i->cur = e; 1.29 + *elm = e->data; 1.30 + return 0; 1.31 + } 1.32 + 1.33 + e = e->next; 1.34 + } else { 1.35 + i->index++; 1.36 + 1.37 + if(i->index < i->map->size) { 1.38 + e = i->map->map[i->index]; 1.39 + } 1.40 + } 1.41 + } 1.42 + 1.43 + return 1; 1.44 +}