293 // advance |
293 // advance |
294 elm = next; |
294 elm = next; |
295 } else { |
295 } else { |
296 // just advance |
296 // just advance |
297 elm = elm->next; |
297 elm = elm->next; |
298 } |
298 iter->index++; |
299 |
299 } |
300 // do we leave the bucket? |
300 |
301 if (elm == NULL) { |
301 // search the next bucket, if required |
302 // search the next bucket |
302 while (elm == NULL && ++iter->slot < map->bucket_count) { |
303 for (; elm == NULL && iter->slot < map->bucket_count; iter->slot++) { |
303 elm = map->buckets[iter->slot]; |
304 elm = map->buckets[iter->slot]; |
304 } |
305 } |
305 |
306 } |
306 // fill the struct with the next element |
307 |
|
308 // advance the index in any case |
|
309 iter->index++; |
|
310 |
|
311 // fill the struct with the current element |
|
312 iter->elem_handle = elm; |
307 iter->elem_handle = elm; |
313 if (elm == NULL) { |
308 if (elm == NULL) { |
314 iter->kv_data.key = NULL; |
309 iter->kv_data.key = NULL; |
315 iter->kv_data.value = NULL; |
310 iter->kv_data.value = NULL; |
316 } else { |
311 } else { |
332 iter.index = 0; |
327 iter.index = 0; |
333 iter.remove = false; |
328 iter.remove = false; |
334 |
329 |
335 if (map->size > 0) { |
330 if (map->size > 0) { |
336 struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; |
331 struct cx_hash_map_s *hash_map = (struct cx_hash_map_s *) map; |
337 struct cx_hash_map_element_s *elm = NULL; |
332 struct cx_hash_map_element_s *elm = hash_map->buckets[0]; |
338 for (; elm == NULL; iter.slot++) { |
333 for (; elm == NULL; iter.slot++) { |
339 elm = hash_map->buckets[iter.slot]; |
334 elm = hash_map->buckets[iter.slot]; |
340 } |
335 } |
341 iter.elem_handle = elm; |
336 iter.elem_handle = elm; |
342 iter.kv_data.key = &elm->key; |
337 iter.kv_data.key = &elm->key; |