146 h *= m; |
146 h *= m; |
147 h ^= h >> 15; |
147 h ^= h >> 15; |
148 |
148 |
149 return h; |
149 return h; |
150 } |
150 } |
|
151 |
|
152 UcxMapIterator ucx_map_iterator(UcxMap *map) { |
|
153 UcxMapIterator i; |
|
154 i.map = map; |
|
155 i.cur = NULL; |
|
156 i.index = 0; |
|
157 return i; |
|
158 } |
|
159 |
|
160 int ucx_map_iter_next(UcxMapIterator *i, void **elm) { |
|
161 UcxMapElement *e = i->cur; |
|
162 |
|
163 if(e == NULL) { |
|
164 e = i->map->map[0]; |
|
165 } else { |
|
166 e = e->next; |
|
167 } |
|
168 |
|
169 while(i->index < i->map->size) { |
|
170 if(e != NULL) { |
|
171 if(e->data != NULL) { |
|
172 i->cur = e; |
|
173 *elm = e->data; |
|
174 return 0; |
|
175 } |
|
176 |
|
177 e = e->next; |
|
178 } else { |
|
179 i->index++; |
|
180 |
|
181 if(i->index < i->map->size) { |
|
182 e = i->map->map[i->index]; |
|
183 } |
|
184 } |
|
185 } |
|
186 |
|
187 return 1; |
|
188 } |