279 return iter->elem != NULL; |
279 return iter->elem != NULL; |
280 } |
280 } |
281 |
281 |
282 static void cx_hash_map_iter_next(void *it) { |
282 static void cx_hash_map_iter_next(void *it) { |
283 CxMapIterator *iter = it; |
283 CxMapIterator *iter = it; |
284 CxMap *map = iter->map.m; |
284 CxMap *map = iter->map; |
285 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map; |
285 struct cx_hash_map_s *hmap = (struct cx_hash_map_s *) map; |
286 struct cx_hash_map_element_s *elm = iter->elem; |
286 struct cx_hash_map_element_s *elm = iter->elem; |
287 |
287 |
288 // remove current element, if asked |
288 // remove current element, if asked |
289 if (iter->base.remove) { |
289 if (iter->base.remove) { |
327 // copy data to a location where the iterator can point to |
327 // copy data to a location where the iterator can point to |
328 // we need to do it here, because the iterator function call |
328 // we need to do it here, because the iterator function call |
329 // must not modify the iterator (the parameter is const) |
329 // must not modify the iterator (the parameter is const) |
330 if (elm != NULL) { |
330 if (elm != NULL) { |
331 iter->entry.key = &elm->key; |
331 iter->entry.key = &elm->key; |
332 if (iter->map.c->collection.store_pointer) { |
332 if (map->collection.store_pointer) { |
333 iter->entry.value = *(void **) elm->data; |
333 iter->entry.value = *(void **) elm->data; |
334 } else { |
334 } else { |
335 iter->entry.value = elm->data; |
335 iter->entry.value = elm->data; |
336 } |
336 } |
337 } |
337 } |
364 } |
364 } |
365 |
365 |
366 iter.base.valid = cx_hash_map_iter_valid; |
366 iter.base.valid = cx_hash_map_iter_valid; |
367 iter.base.next = cx_hash_map_iter_next; |
367 iter.base.next = cx_hash_map_iter_next; |
368 iter.base.remove = false; |
368 iter.base.remove = false; |
369 iter.base.mutating = false; |
369 iter.base.allow_remove = true; |
370 |
370 |
371 iter.slot = 0; |
371 iter.slot = 0; |
372 iter.index = 0; |
372 iter.index = 0; |
373 |
373 |
374 if (map->collection.size > 0) { |
374 if (map->collection.size > 0) { |