385 static inline size_t cxListAddArray( |
386 static inline size_t cxListAddArray( |
386 CxList *list, |
387 CxList *list, |
387 const void *array, |
388 const void *array, |
388 size_t n |
389 size_t n |
389 ) { |
390 ) { |
|
391 list->collection.sorted = false; |
390 return list->cl->insert_array(list, list->collection.size, array, n); |
392 return list->cl->insert_array(list, list->collection.size, array, n); |
391 } |
393 } |
392 |
394 |
393 /** |
395 /** |
394 * Inserts an item at the specified index. |
396 * Inserts an item at the specified index. |
407 static inline int cxListInsert( |
409 static inline int cxListInsert( |
408 CxList *list, |
410 CxList *list, |
409 size_t index, |
411 size_t index, |
410 const void *elem |
412 const void *elem |
411 ) { |
413 ) { |
|
414 list->collection.sorted = false; |
412 return list->cl->insert_element(list, index, elem); |
415 return list->cl->insert_element(list, index, elem); |
413 } |
416 } |
414 |
417 |
415 /** |
418 /** |
416 * Inserts an item into a sorted list. |
419 * Inserts an item into a sorted list. |
|
420 * |
|
421 * If the list is not sorted already, the behavior is undefined. |
417 * |
422 * |
418 * @param list the list |
423 * @param list the list |
419 * @param elem a pointer to the element to add |
424 * @param elem a pointer to the element to add |
420 * @retval zero success |
425 * @retval zero success |
421 * @retval non-zero memory allocation failure |
426 * @retval non-zero memory allocation failure |
467 * If there is not enough memory to add all elements, the returned value is |
474 * If there is not enough memory to add all elements, the returned value is |
468 * less than @p n. |
475 * less than @p n. |
469 * |
476 * |
470 * If this list is storing pointers instead of objects @p array is expected to |
477 * If this list is storing pointers instead of objects @p array is expected to |
471 * be an array of pointers. |
478 * be an array of pointers. |
|
479 * |
|
480 * If the list is not sorted already, the behavior is undefined. |
472 * |
481 * |
473 * @param list the list |
482 * @param list the list |
474 * @param array a pointer to the elements to add |
483 * @param array a pointer to the elements to add |
475 * @param n the number of elements to add |
484 * @param n the number of elements to add |
476 * @return the number of added elements |
485 * @return the number of added elements |
503 cx_attr_nonnull |
513 cx_attr_nonnull |
504 static inline int cxListInsertAfter( |
514 static inline int cxListInsertAfter( |
505 CxIterator *iter, |
515 CxIterator *iter, |
506 const void *elem |
516 const void *elem |
507 ) { |
517 ) { |
508 return ((struct cx_list_s *) iter->src_handle.m)->cl->insert_iter(iter, elem, 0); |
518 CxList* list = iter->src_handle.m; |
|
519 list->collection.sorted = false; |
|
520 return list->cl->insert_iter(iter, elem, 0); |
509 } |
521 } |
510 |
522 |
511 /** |
523 /** |
512 * Inserts an element before the current location of the specified iterator. |
524 * Inserts an element before the current location of the specified iterator. |
513 * |
525 * |
527 cx_attr_nonnull |
539 cx_attr_nonnull |
528 static inline int cxListInsertBefore( |
540 static inline int cxListInsertBefore( |
529 CxIterator *iter, |
541 CxIterator *iter, |
530 const void *elem |
542 const void *elem |
531 ) { |
543 ) { |
532 return ((struct cx_list_s *) iter->src_handle.m)->cl->insert_iter(iter, elem, 1); |
544 CxList* list = iter->src_handle.m; |
|
545 list->collection.sorted = false; |
|
546 return list->cl->insert_iter(iter, elem, 1); |
533 } |
547 } |
534 |
548 |
535 /** |
549 /** |
536 * Removes the element at the specified index. |
550 * Removes the element at the specified index. |
537 * |
551 * |
872 * @param list the list |
888 * @param list the list |
873 */ |
889 */ |
874 cx_attr_nonnull |
890 cx_attr_nonnull |
875 static inline void cxListSort(CxList *list) { |
891 static inline void cxListSort(CxList *list) { |
876 list->cl->sort(list); |
892 list->cl->sort(list); |
|
893 list->collection.sorted = true; |
877 } |
894 } |
878 |
895 |
879 /** |
896 /** |
880 * Reverses the order of the items. |
897 * Reverses the order of the items. |
881 * |
898 * |
882 * @param list the list |
899 * @param list the list |
883 */ |
900 */ |
884 cx_attr_nonnull |
901 cx_attr_nonnull |
885 static inline void cxListReverse(CxList *list) { |
902 static inline void cxListReverse(CxList *list) { |
|
903 // still sorted, but not according to the cmp_func |
|
904 list->collection.sorted = false; |
886 list->cl->reverse(list); |
905 list->cl->reverse(list); |
887 } |
906 } |
888 |
907 |
889 /** |
908 /** |
890 * Compares a list to another list of the same type. |
909 * Compares a list to another list of the same type. |