src/cx/list.h

changeset 1180
4c3a69b9723a
parent 1163
68ff0839bc6a
equal deleted inserted replaced
1179:ca4c6f590a08 1180:4c3a69b9723a
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 );
259 * version for your list. 261 * version for your list.
260 * 262 *
261 * @param list the list that shall be sorted 263 * @param list the list that shall be sorted
262 */ 264 */
263 cx_attr_nonnull 265 cx_attr_nonnull
266 cx_attr_export
264 void cx_list_default_sort(struct cx_list_s *list); 267 void cx_list_default_sort(struct cx_list_s *list);
265 268
266 /** 269 /**
267 * Default unoptimized swap implementation. 270 * Default unoptimized swap implementation.
268 * 271 *
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,
737 * @param index the index where the iterator shall point at 742 * @param index the index where the iterator shall point at
738 * @return a new iterator 743 * @return a new iterator
739 */ 744 */
740 cx_attr_nonnull 745 cx_attr_nonnull
741 cx_attr_nodiscard 746 cx_attr_nodiscard
747 cx_attr_export
742 CxIterator cxListMutIteratorAt( 748 CxIterator cxListMutIteratorAt(
743 CxList *list, 749 CxList *list,
744 size_t index 750 size_t index
745 ); 751 );
746 752
756 * @param index the index where the iterator shall point at 762 * @param index the index where the iterator shall point at
757 * @return a new iterator 763 * @return a new iterator
758 */ 764 */
759 cx_attr_nonnull 765 cx_attr_nonnull
760 cx_attr_nodiscard 766 cx_attr_nodiscard
767 cx_attr_export
761 CxIterator cxListMutBackwardsIteratorAt( 768 CxIterator cxListMutBackwardsIteratorAt(
762 CxList *list, 769 CxList *list,
763 size_t index 770 size_t index
764 ); 771 );
765 772
919 * @retval positive the first list is larger 926 * @retval positive the first list is larger
920 * or the first non-equal element in the first list is larger 927 * or the first non-equal element in the first list is larger
921 */ 928 */
922 cx_attr_nonnull 929 cx_attr_nonnull
923 cx_attr_nodiscard 930 cx_attr_nodiscard
931 cx_attr_export
924 int cxListCompare( 932 int cxListCompare(
925 const CxList *list, 933 const CxList *list,
926 const CxList *other 934 const CxList *other
927 ); 935 );
928 936
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"

mercurial