217 * @param data a pointer to the array of data to insert |
217 * @param data a pointer to the array of data to insert |
218 * @param n the number of elements to insert |
218 * @param n the number of elements to insert |
219 * @return the number of elements actually inserted |
219 * @return the number of elements actually inserted |
220 */ |
220 */ |
221 cx_attr_nonnull |
221 cx_attr_nonnull |
|
222 cx_attr_export |
222 size_t cx_list_default_insert_array( |
223 size_t cx_list_default_insert_array( |
223 struct cx_list_s *list, |
224 struct cx_list_s *list, |
224 size_t index, |
225 size_t index, |
225 const void *data, |
226 const void *data, |
226 size_t n |
227 size_t n |
241 * @param sorted_data a pointer to the array of pre-sorted data to insert |
242 * @param sorted_data a pointer to the array of pre-sorted data to insert |
242 * @param n the number of elements to insert |
243 * @param n the number of elements to insert |
243 * @return the number of elements actually inserted |
244 * @return the number of elements actually inserted |
244 */ |
245 */ |
245 cx_attr_nonnull |
246 cx_attr_nonnull |
|
247 cx_attr_export |
246 size_t cx_list_default_insert_sorted( |
248 size_t cx_list_default_insert_sorted( |
247 struct cx_list_s *list, |
249 struct cx_list_s *list, |
248 const void *sorted_data, |
250 const void *sorted_data, |
249 size_t n |
251 size_t n |
250 ); |
252 ); |
275 * @retval zero success |
278 * @retval zero success |
276 * @retval non-zero when indices are out of bounds or memory |
279 * @retval non-zero when indices are out of bounds or memory |
277 * allocation for the temporary buffer fails |
280 * allocation for the temporary buffer fails |
278 */ |
281 */ |
279 cx_attr_nonnull |
282 cx_attr_nonnull |
|
283 cx_attr_export |
280 int cx_list_default_swap(struct cx_list_s *list, size_t i, size_t j); |
284 int cx_list_default_swap(struct cx_list_s *list, size_t i, size_t j); |
281 |
285 |
282 /** |
286 /** |
283 * Initializes a list struct. |
287 * Initializes a list struct. |
284 * |
288 * |
322 * @param allocator the allocator for the elements |
326 * @param allocator the allocator for the elements |
323 * @param comparator a compare function for the elements |
327 * @param comparator a compare function for the elements |
324 * @param elem_size the size of one element |
328 * @param elem_size the size of one element |
325 */ |
329 */ |
326 cx_attr_nonnull_arg(1, 2, 3) |
330 cx_attr_nonnull_arg(1, 2, 3) |
|
331 cx_attr_export |
327 void cx_list_init( |
332 void cx_list_init( |
328 struct cx_list_s *list, |
333 struct cx_list_s *list, |
329 struct cx_list_class_s *cl, |
334 struct cx_list_class_s *cl, |
330 const struct cx_allocator_s *allocator, |
335 const struct cx_allocator_s *allocator, |
331 cx_compare_func comparator, |
336 cx_compare_func comparator, |
931 * |
939 * |
932 * Also calls the content destructor functions for each element, if specified. |
940 * Also calls the content destructor functions for each element, if specified. |
933 * |
941 * |
934 * @param list the list which shall be freed |
942 * @param list the list which shall be freed |
935 */ |
943 */ |
|
944 cx_attr_export |
936 void cxListFree(CxList *list); |
945 void cxListFree(CxList *list); |
937 |
946 |
938 /** |
947 /** |
939 * A shared instance of an empty list. |
948 * A shared instance of an empty list. |
940 * |
949 * |
941 * Writing to that list is not allowed. |
950 * Writing to that list is not allowed. |
942 * |
951 * |
943 * You can use this is a placeholder for initializing CxList pointers |
952 * You can use this is a placeholder for initializing CxList pointers |
944 * for which you do not want to reserve memory right from the beginning. |
953 * for which you do not want to reserve memory right from the beginning. |
945 */ |
954 */ |
|
955 cx_attr_export |
946 extern CxList *const cxEmptyList; |
956 extern CxList *const cxEmptyList; |
947 |
957 |
948 |
958 |
949 #ifdef __cplusplus |
959 #ifdef __cplusplus |
950 } // extern "C" |
960 } // extern "C" |