src/linked_list.c

changeset 874
cdce47f34d48
parent 856
6bbbf219251d
child 876
f4ce7df9cff0
equal deleted inserted replaced
872:d607a184925a 874:cdce47f34d48
890 cx_linked_list_node *node = iter->elem_handle; 890 cx_linked_list_node *node = iter->elem_handle;
891 if (node != NULL) { 891 if (node != NULL) {
892 assert(prepend >= 0 && prepend <= 1); 892 assert(prepend >= 0 && prepend <= 1);
893 cx_linked_list_node *choice[2] = {node, node->prev}; 893 cx_linked_list_node *choice[2] = {node, node->prev};
894 int result = cx_ll_insert_at(list, choice[prepend], elem); 894 int result = cx_ll_insert_at(list, choice[prepend], elem);
895 iter->index += prepend * (0 == result); 895 if (result == 0) {
896 iter->elem_count++;
897 if (prepend) {
898 iter->index++;
899 }
900 }
896 return result; 901 return result;
897 } else { 902 } else {
898 int result = cx_ll_insert_element(list, list->collection.size, elem); 903 int result = cx_ll_insert_element(list, list->collection.size, elem);
899 iter->index = list->collection.size; 904 if (result == 0) {
905 iter->elem_count++;
906 iter->index = list->collection.size;
907 }
900 return result; 908 return result;
901 } 909 }
902 } 910 }
903 911
904 static void cx_ll_destructor(CxList *list) { 912 static void cx_ll_destructor(CxList *list) {

mercurial