# HG changeset patch # User Mike Becker # Date 1766065996 -3600 # Node ID 27e7a4bf1a3969f24e483c43a4b12334fecdf8de # Parent c52a4c67e29ee16cadad89946cd44d38f020f1e0 add missing compare_func2 variants of the array functions - relates to #622 diff -r c52a4c67e29e -r 27e7a4bf1a39 docs/Writerside/topics/array_list.h.md --- a/docs/Writerside/topics/array_list.h.md Thu Dec 18 12:26:25 2025 +0100 +++ b/docs/Writerside/topics/array_list.h.md Thu Dec 18 14:53:16 2025 +0100 @@ -144,17 +144,36 @@ #include int cx_array_insert_sorted(CxArray array, - cx_compare_func cmp_func, const void *element); + const void *element, + cx_compare_func cmp_func); int cx_array_insert_sorted_array(CxArray array, - cx_compare_func cmp_func, const void *sorted_data, size_t n); + const void *sorted_data, size_t n, + cx_compare_func cmp_func); int cx_array_insert_sorted_a(const CxAllocator *allocator, - CxArray array, cx_compare_func cmp_func, const void *element); + CxArray array, const void *element, + cx_compare_func cmp_func); int cx_array_insert_sorted_array_a(const CxAllocator *allocator, - CxArray array, cx_compare_func cmp_func, - const void *sorted_data, size_t n); + CxArray array, const void *sorted_data, size_t n, + cx_compare_func cmp_func); + +int cx_array_insert_sorted_c(CxArray array, + const void *element, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_sorted_array_c(CxArray array, + const void *sorted_data, size_t n, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_sorted_ca(const CxAllocator *allocator, + CxArray array, const void *element, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_sorted_array_ca(const CxAllocator *allocator, + CxArray array, const void *sorted_data, size_t n, + cx_compare_func2 cmp_func, void *context); ``` The above functions are equivalent to `cx_array_insert()` and `cx_array_insert_array()`, @@ -167,17 +186,36 @@ #include int cx_array_insert_unique(CxArray array, - cx_compare_func cmp_func, const void *element); + const void *element, + cx_compare_func cmp_func); int cx_array_insert_unique_array(CxArray array, - cx_compare_func cmp_func, const void *sorted_data, size_t n); + const void *sorted_data, size_t n, + cx_compare_func cmp_func); int cx_array_insert_unique_a(const CxAllocator *allocator, - CxArray array, cx_compare_func cmp_func, const void *element); + CxArray array, const void *element, + cx_compare_func cmp_func); int cx_array_insert_unique_array_a(const CxAllocator *allocator, - CxArray array, cx_compare_func cmp_func, - const void *sorted_data, size_t n); + CxArray array, const void *sorted_data, size_t n, + cx_compare_func cmp_func); + +int cx_array_insert_unique_c(CxArray array, + const void *element, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_unique_array_c(CxArray array, + const void *sorted_data, size_t n, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_unique_ca(const CxAllocator *allocator, + CxArray array, const void *element, + cx_compare_func2 cmp_func, void *context); + +int cx_array_insert_unique_array_ca(const CxAllocator *allocator, + CxArray array, const void *sorted_data, size_t n, + cx_compare_func2 cmp_func, void *context); ``` The above functions are similar to the functions for insertion sort, diff -r c52a4c67e29e -r 27e7a4bf1a39 src/array_list.c --- a/src/array_list.c Thu Dec 18 12:26:25 2025 +0100 +++ b/src/array_list.c Thu Dec 18 14:53:16 2025 +0100 @@ -131,15 +131,15 @@ return 0; } -int cx_array_insert_sorted_s_( +int cx_array_insert_sorted_c_( const CxAllocator *allocator, CxArray *array, size_t elem_size, const void *sorted_data, size_t n, - bool allow_duplicates, cx_compare_func2 cmp_func, - void *context + void *context, + bool allow_duplicates ) { // assert pointers assert(allocator != NULL); @@ -343,14 +343,14 @@ const CxAllocator *allocator, CxArray *array, size_t elem_size, - cx_compare_func cmp_func, const void *sorted_data, size_t n, + cx_compare_func cmp_func, bool allow_duplicates ) { cx_compare_func_wrapper wrapper = {cmp_func}; - return cx_array_insert_sorted_s_(allocator, array, elem_size, sorted_data, - n, allow_duplicates, cx_acmp_wrap, &wrapper); + return cx_array_insert_sorted_c_(allocator, array, elem_size, sorted_data, + n, cx_acmp_wrap, &wrapper, allow_duplicates); } #ifndef WITH_QSORT_R @@ -664,15 +664,15 @@ arl->data, list->collection.size, arl->capacity }; - if (cx_array_insert_sorted_s_( + if (cx_array_insert_sorted_c_( list->collection.allocator, &wrap, list->collection.elem_size, sorted_data, n, - allow_duplicates, cx_list_compare_wrapper, - list + list, + allow_duplicates )) { // array list implementation is "all or nothing" return 0; // LCOV_EXCL_LINE diff -r c52a4c67e29e -r 27e7a4bf1a39 src/cx/array_list.h --- a/src/cx/array_list.h Thu Dec 18 12:26:25 2025 +0100 +++ b/src/cx/array_list.h Thu Dec 18 14:53:16 2025 +0100 @@ -397,17 +397,17 @@ * @param allocator the allocator to use for a possible reallocation * @param array a pointer to the array structure * @param elem_size the size of one element - * @param cmp_func * @param sorted_data a pointer to an array of data that shall be inserted * @param n the number of elements that shall be inserted + * @param cmp_func the compare function * @param allow_duplicates @c false if duplicates shall be skipped during insertion * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ cx_attr_nonnull CX_EXPORT int cx_array_insert_sorted_(const CxAllocator *allocator, CxArray *array, - size_t elem_size, cx_compare_func cmp_func, const void *sorted_data, size_t n, - bool allow_duplicates); + size_t elem_size, const void *sorted_data, size_t n, + cx_compare_func cmp_func, bool allow_duplicates); /** * Inserts an element into a sorted array. @@ -418,13 +418,13 @@ * * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted * @param cmp_func (@c cx_compare_func) the compare function that establishes the order - * @param element (@c void*) a pointer to element that shall be inserted * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_sorted_a(allocator, array, cmp_func, element) \ - cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), cmp_func, element, 1, true) +#define cx_array_insert_sorted_a(allocator, array, element, cmp_func) \ + cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), element, 1, cmp_func, true) /** * Inserts an element into a sorted array. @@ -434,13 +434,13 @@ * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. * * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted * @param cmp_func (@c cx_compare_func) the compare function that establishes the order - * @param element (@c void*) a pointer to element that shall be inserted * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_sorted(array, cmp_func, element) \ - cx_array_insert_sorted_a(cxDefaultAllocator, array, cmp_func, element) +#define cx_array_insert_sorted(array, element, cmp_func) \ + cx_array_insert_sorted_a(cxDefaultAllocator, array, element, cmp_func) /** * Inserts sorted data into a sorted array. @@ -451,14 +451,14 @@ * * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation * @param array the name of the array where the elements shall be inserted - * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_sorted_array_a(allocator, array, cmp_func, sorted_data, n) \ - cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), cmp_func, sorted_data, n, true) +#define cx_array_insert_sorted_array_a(allocator, array, sorted_data, n, cmp_func) \ + cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), sorted_data, n, cmp_func, true) /** * Inserts sorted data into a sorted array. @@ -468,14 +468,14 @@ * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. * * @param array the name of the array where the elements shall be inserted - * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_sorted_array(array, cmp_func, sorted_data, n) \ - cx_array_insert_sorted_array_a(cxDefaultAllocator, array, cmp_func, sorted_data, n) +#define cx_array_insert_sorted_array(array, sorted_data, n, cmp_func) \ + cx_array_insert_sorted_array_a(cxDefaultAllocator, array, sorted_data, n, cmp_func) /** * Inserts an element into a sorted array if it is not already contained. @@ -486,13 +486,13 @@ * * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted * @param cmp_func (@c cx_compare_func) the compare function that establishes the order - * @param element (@c void*) a pointer to element that shall be inserted * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_unique_a(allocator, array, cmp_func, element) \ - cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), cmp_func, element, 1, false) +#define cx_array_insert_unique_a(allocator, array, element, cmp_func) \ + cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), element, 1, cmp_func, false) /** * Inserts an element into a sorted array if it is not already contained. @@ -502,13 +502,13 @@ * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. * * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted * @param cmp_func (@c cx_compare_func) the compare function that establishes the order - * @param element (@c void*) a pointer to element that shall be inserted * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_unique(array, cmp_func, element) \ - cx_array_insert_unique_a(cxDefaultAllocator, array, cmp_func, element) +#define cx_array_insert_unique(array, element, cmp_func) \ + cx_array_insert_unique_a(cxDefaultAllocator, array, element, cmp_func) /** * Inserts sorted data into a sorted array, skipping duplicates. @@ -519,14 +519,14 @@ * * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation * @param array the name of the array where the elements shall be inserted - * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_unique_array_a(allocator, array, cmp_func, sorted_data, n) \ - cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), cmp_func, sorted_data, n, false) +#define cx_array_insert_unique_array_a(allocator, array, sorted_data, n, cmp_func) \ + cx_array_insert_sorted_(allocator, (CxArray*)&(array), sizeof((array).data[0]), sorted_data, n, cmp_func, false) /** * Inserts sorted data into a sorted array, skipping duplicates. @@ -536,14 +536,179 @@ * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. * * @param array the name of the array where the elements shall be inserted - * @param cmp_func (@c cx_compare_func) the compare function that establishes the order * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func) the compare function that establishes the order + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_unique_array(array, sorted_data, n, cmp_func) \ + cx_array_insert_unique_array_a(cxDefaultAllocator, array, sorted_data, n, cmp_func) + +/** + * Inserts sorted data into a sorted array. + * + * Internal function - do not use. + * + * @param allocator the allocator to use for a possible reallocation + * @param array a pointer to the array structure + * @param elem_size the size of one element + * @param sorted_data a pointer to an array of data that shall be inserted + * @param n the number of elements that shall be inserted + * @param cmp_func the compare function + * @param context additional context for the compare function + * @param allow_duplicates @c false if duplicates shall be skipped during insertion + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +cx_attr_nonnull +CX_EXPORT int cx_array_insert_sorted_c_(const CxAllocator *allocator, CxArray *array, + size_t elem_size, const void *sorted_data, size_t n, + cx_compare_func2 cmp_func, void *context, bool allow_duplicates); + +/** + * Inserts an element into a sorted array. + * + * When the capacity is not enough to hold the new element, a re-allocation is attempted. + * + * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation + * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_sorted_ca(allocator, array, element, cmp_func) \ + cx_array_insert_sorted_c_(allocator, (CxArray*)&(array), sizeof((array).data[0]), element, 1, cmp_func, context, true) + +/** + * Inserts an element into a sorted array. + * + * When the capacity is not enough to hold the new element, a re-allocation is attempted. + * + * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_sorted_c(array, element, cmp_func, context) \ + cx_array_insert_sorted_ca(cxDefaultAllocator, array, element, cmp_func, context) + +/** + * Inserts sorted data into a sorted array. + * + * When the capacity is not enough to hold the new elements, a re-allocation is attempted. + * + * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation + * @param array the name of the array where the elements shall be inserted + * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted + * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function * @retval zero success * @retval non-zero a re-allocation was necessary but failed */ -#define cx_array_insert_unique_array(array, cmp_func, sorted_data, n) \ - cx_array_insert_unique_array_a(cxDefaultAllocator, array, cmp_func, sorted_data, n) +#define cx_array_insert_sorted_array_ca(allocator, array, sorted_data, n, cmp_func, context) \ + cx_array_insert_sorted_c_(allocator, (CxArray*)&(array), sizeof((array).data[0]), sorted_data, n, cmp_func, context, true) + +/** + * Inserts sorted data into a sorted array. + * + * When the capacity is not enough to hold the new elements, a re-allocation is attempted. + * + * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param array the name of the array where the elements shall be inserted + * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted + * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_sorted_array_c(array, sorted_data, n, cmp_func, context) \ + cx_array_insert_sorted_array_ca(cxDefaultAllocator, array, sorted_data, n, cmp_func, context) + +/** + * Inserts an element into a sorted array if it is not already contained. + * + * When the capacity is not enough to hold the new element, a re-allocation is attempted. + * + * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation + * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_unique_ca(allocator, array, element, cmp_func, context) \ + cx_array_insert_sorted_c_(allocator, (CxArray*)&(array), sizeof((array).data[0]), element, 1, cmp_func, context, false) + +/** + * Inserts an element into a sorted array if it is not already contained. + * + * When the capacity is not enough to hold the new element, a re-allocation is attempted. + * + * @attention if the array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param array the name of the array where the elements shall be inserted + * @param element (@c void*) a pointer to element that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_unique_c(array, element, cmp_func, context) \ + cx_array_insert_unique_ca(cxDefaultAllocator, array, element, cmp_func, context) + +/** + * Inserts sorted data into a sorted array, skipping duplicates. + * + * When the capacity is not enough to hold the new elements, a re-allocation is attempted. + * + * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param allocator (@c CxAllocator*) the allocator to use for a possible reallocation + * @param array the name of the array where the elements shall be inserted + * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted + * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_unique_array_ca(allocator, array, sorted_data, n, cmp_func, context) \ + cx_array_insert_sorted_c_(allocator, (CxArray*)&(array), sizeof((array).data[0]), sorted_data, n, cmp_func, context, false) + +/** + * Inserts sorted data into a sorted array, skipping duplicates. + * + * When the capacity is not enough to hold the new elements, a re-allocation is attempted. + * + * @attention if either array is not sorted according to the specified @p cmp_func, the behavior is undefined. + * + * @param array the name of the array where the elements shall be inserted + * @param sorted_data (@c void*) a pointer to an array of sorted data that shall be inserted + * @param n (@c size_t) the number of elements that shall be inserted + * @param cmp_func (@c cx_compare_func2) the compare function that establishes the order + * @param context (@c void*) additional context for the compare function + * @retval zero success + * @retval non-zero a re-allocation was necessary but failed + */ +#define cx_array_insert_unique_array_c(array, sorted_data, n, cmp_func, context) \ + cx_array_insert_unique_array_ca(cxDefaultAllocator, array, sorted_data, n, cmp_func, context) /** * An alternative to qsort_r() when that is not available on your platform. diff -r c52a4c67e29e -r 27e7a4bf1a39 tests/test_list.c --- a/tests/test_list.c Thu Dec 18 12:26:25 2025 +0100 +++ b/tests/test_list.c Thu Dec 18 14:53:16 2025 +0100 @@ -154,40 +154,40 @@ cx_array_init(array, 4); CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d1)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d1, cx_cmp_int)); CX_TEST_ASSERT(array.size == 1); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d2)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d2, cx_cmp_int)); CX_TEST_ASSERT(array.size == 2); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d3)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d3, cx_cmp_int)); CX_TEST_ASSERT(array.size == 3); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d4)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d4, cx_cmp_int)); CX_TEST_ASSERT(array.size == 4); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d5)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d5, cx_cmp_int)); CX_TEST_ASSERT(array.size == 5); CX_TEST_ASSERT(array.capacity >= 5); - CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, cx_cmp_int, d6a, 6)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, d6a, 6, cx_cmp_int)); CX_TEST_ASSERT(array.size == 11); CX_TEST_ASSERT(array.capacity >= 11); - CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, cx_cmp_int, d7a, 6)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, d7a, 6, cx_cmp_int)); CX_TEST_ASSERT(array.size == 17); CX_TEST_ASSERT(array.capacity >= 17); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d8)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d8, cx_cmp_int)); CX_TEST_ASSERT(array.size == 18); CX_TEST_ASSERT(array.capacity >= 18); - CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, cx_cmp_int, &d9)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted(array, &d9, cx_cmp_int)); CX_TEST_ASSERT(array.size == 19); CX_TEST_ASSERT(array.capacity >= 19); - CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, cx_cmp_int, d10a, 3)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, d10a, 3, cx_cmp_int)); CX_TEST_ASSERT(array.size == 22); CX_TEST_ASSERT(array.capacity >= 22); - CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, cx_cmp_int, d11a, 6)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, d11a, 6, cx_cmp_int)); CX_TEST_ASSERT(array.size == 28); CX_TEST_ASSERT(array.capacity >= 28); - CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, cx_cmp_int, d12a, 3)); + CX_TEST_ASSERT(0 == cx_array_insert_sorted_array(array, d12a, 3, cx_cmp_int)); CX_TEST_ASSERT(array.size == 31); CX_TEST_ASSERT(array.capacity >= 31); @@ -217,37 +217,37 @@ cx_array_init(array, 4); CX_TEST_DO { - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d1)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d1, cx_cmp_int)); CX_TEST_ASSERT(array.size == 1); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d2)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d2, cx_cmp_int)); CX_TEST_ASSERT(array.size == 2); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d3)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d3, cx_cmp_int)); CX_TEST_ASSERT(array.size == 3); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d4)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d4, cx_cmp_int)); CX_TEST_ASSERT(array.size == 4); CX_TEST_ASSERT(array.capacity == 4); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d5)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d5, cx_cmp_int)); CX_TEST_ASSERT(array.size == 5); CX_TEST_ASSERT(array.capacity >= 5); - CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, cx_cmp_int, d6a, 6)); + CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, d6a, 6, cx_cmp_int)); CX_TEST_ASSERT(array.size == 11); CX_TEST_ASSERT(array.capacity >= 11); - CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, cx_cmp_int, d7a, 6)); + CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, d7a, 6, cx_cmp_int)); CX_TEST_ASSERT(array.size == 17); CX_TEST_ASSERT(array.capacity >= 17); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d8)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d8, cx_cmp_int)); CX_TEST_ASSERT(array.size == 18); CX_TEST_ASSERT(array.capacity >= 18); - CX_TEST_ASSERT(0 == cx_array_insert_unique(array, cx_cmp_int, &d9)); + CX_TEST_ASSERT(0 == cx_array_insert_unique(array, &d9, cx_cmp_int)); CX_TEST_ASSERT(array.size == 18); CX_TEST_ASSERT(array.capacity >= 18); - CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, cx_cmp_int, d10a, 3)); + CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, d10a, 3, cx_cmp_int)); CX_TEST_ASSERT(array.size == 19); CX_TEST_ASSERT(array.capacity >= 19); - CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, cx_cmp_int, d11a, 8)); + CX_TEST_ASSERT(0 == cx_array_insert_unique_array(array, d11a, 8, cx_cmp_int)); CX_TEST_ASSERT(array.size == 22); CX_TEST_ASSERT(array.capacity >= 22);