222 // array list implementation is "all or nothing" |
222 // array list implementation is "all or nothing" |
223 return 0; |
223 return 0; |
224 } |
224 } |
225 } |
225 } |
226 |
226 |
|
227 static int cx_arl_insert_element( |
|
228 struct cx_list_s *list, |
|
229 size_t index, |
|
230 void const *element |
|
231 ) { |
|
232 return 1 != cx_arl_insert_array(list, index, element, 1); |
|
233 } |
|
234 |
227 static int cx_arl_insert_iter( |
235 static int cx_arl_insert_iter( |
228 struct cx_mut_iterator_s *iter, |
236 struct cx_mut_iterator_s *iter, |
229 void const *elem, |
237 void const *elem, |
230 int prepend |
238 int prepend |
231 ) { |
239 ) { |
232 struct cx_list_s *list = iter->src_handle; |
240 struct cx_list_s *list = iter->src_handle; |
233 if (iter->index < list->size) { |
241 if (iter->index < list->size) { |
234 int result = 1 != cx_arl_insert_array( |
242 int result = cx_arl_insert_element( |
235 list, |
243 list, |
236 iter->index + 1 - prepend, |
244 iter->index + 1 - prepend, |
237 elem, |
245 elem |
238 1 |
|
239 ); |
246 ); |
240 if (result == 0 && prepend != 0) { |
247 if (result == 0 && prepend != 0) { |
241 iter->index++; |
248 iter->index++; |
242 iter->elem_handle = ((char *) iter->elem_handle) + list->itemsize; |
249 iter->elem_handle = ((char *) iter->elem_handle) + list->itemsize; |
243 } |
250 } |
244 return result; |
251 return result; |
245 } else { |
252 } else { |
246 int result = 1 != cx_arl_insert_array(list, list->size, elem, 1); |
253 int result = cx_arl_insert_element(list, list->size, elem); |
247 iter->index = list->size; |
254 iter->index = list->size; |
248 return result; |
255 return result; |
249 } |
256 } |
250 } |
257 } |
251 |
258 |