src/array_list.c

changeset 829
7d4e31d295af
parent 820
8b86ee2e09bb
equal deleted inserted replaced
828:88fa3381206d 829:7d4e31d295af
490 iter->elem_handle = ((char *) list->data) 490 iter->elem_handle = ((char *) list->data)
491 + iter->index * list->base.item_size; 491 + iter->index * list->base.item_size;
492 } 492 }
493 } 493 }
494 494
495 static bool cx_arl_iter_flag_rm(void *it) {
496 struct cx_iterator_base_s *iter = it;
497 if (iter->mutating) {
498 iter->remove = true;
499 return true;
500 } else {
501 return false;
502 }
503 }
504 495
505 static struct cx_iterator_s cx_arl_iterator( 496 static struct cx_iterator_s cx_arl_iterator(
506 struct cx_list_s const *list, 497 struct cx_list_s const *list,
507 size_t index, 498 size_t index,
508 bool backwards 499 bool backwards
513 iter.src_handle = list; 504 iter.src_handle = list;
514 iter.elem_handle = cx_arl_at(list, index); 505 iter.elem_handle = cx_arl_at(list, index);
515 iter.base.valid = cx_arl_iter_valid; 506 iter.base.valid = cx_arl_iter_valid;
516 iter.base.current = cx_arl_iter_current; 507 iter.base.current = cx_arl_iter_current;
517 iter.base.next = backwards ? cx_arl_iter_prev : cx_arl_iter_next; 508 iter.base.next = backwards ? cx_arl_iter_prev : cx_arl_iter_next;
518 iter.base.flag_removal = cx_arl_iter_flag_rm;
519 iter.base.remove = false; 509 iter.base.remove = false;
520 iter.base.mutating = false; 510 iter.base.mutating = false;
521 511
522 return iter; 512 return iter;
523 } 513 }

mercurial