src/cx/array_list.h

changeset 1608
46d8a8305948
parent 1607
0ecb13118cac
--- a/src/cx/array_list.h	Sun Dec 14 23:17:48 2025 +0100
+++ b/src/cx/array_list.h	Mon Dec 15 19:00:51 2025 +0100
@@ -65,46 +65,77 @@
 cx_attr_nonnull
 CX_EXPORT int cx_array_init_(const CxAllocator *allocator, CxArray *array, size_t elem_size, size_t capacity);
 
-#define cx_array_init(array, capacity) cx_array_init_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
+#define cx_array_init_a(allocator, array, capacity) cx_array_init_(allocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
+
+#define cx_array_init(array, capacity) cx_array_init_a(cxDefaultAllocator, array, capacity)
 
-#define cx_array_init_a(allocator, array, capacity) cx_array_init_(allocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
+cx_attr_nonnull
+CX_EXPORT void cx_array_init_fixed_(CxArray *array, const void *data, size_t capacity, size_t size);
+
+#define cx_array_init_fixed(array, fixed_size_array, num_initialized) cx_array_init_fixed_((CxArray*)&(array), fixed_size_array, cx_nmemb(fixed_size_array), num_initialized)
 
 cx_attr_nonnull
 CX_EXPORT int cx_array_reserve_(const CxAllocator *allocator, CxArray *array, size_t elem_size, size_t capacity);
 
-#define cx_array_reserve(array, capacity) cx_array_reserve_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
+#define cx_array_reserve_a(allocator, array, capacity) cx_array_reserve_(allocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
 
-#define cx_array_reserve_a(allocator, array, capacity) cx_array_reserve_(allocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
+#define cx_array_reserve(array, capacity) cx_array_reserve_a(cxDefaultAllocator, array, capacity)
 
 cx_attr_nonnull
 CX_EXPORT int cx_array_move_to_new_(const CxAllocator *allocator, CxArray *array, size_t elem_size, size_t capacity);
 
-#define cx_array_move_to_new(array, capacity) cx_array_move_to_new_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
-
 #define cx_array_move_to_new_a(allocator, array, capacity) cx_array_move_to_new_(allocator, (CxArray*)&(array), sizeof((array).data[0]), capacity)
 
-cx_attr_nonnull
-CX_EXPORT int cx_array_add_(const CxAllocator *allocator, CxArray *array, size_t elem_size, void *element);
-
-#define cx_array_add(array, element) cx_array_add_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), element)
-
-#define cx_array_add_a(allocator, array, element) cx_array_add_(allocator, (CxArray*)&(array), sizeof((array).data[0]), element)
+#define cx_array_move_to_new(array, capacity) cx_array_move_to_new_a(cxDefaultAllocator, array, capacity)
 
 cx_attr_nonnull_arg(1, 2)
-CX_EXPORT int cx_array_insert_array_(const CxAllocator *allocator, CxArray *array,
+CX_EXPORT int cx_array_insert_(const CxAllocator *allocator, CxArray *array,
         size_t elem_size, size_t index, const void *other, size_t n);
 
-#define cx_array_insert_array(array, index, other, n) \
-        cx_array_insert_array_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), index, other, n)
+#define cx_array_add_a(allocator, array, element) \
+        cx_array_insert_(allocator, (CxArray*)&(array), sizeof((array).data[0]), (array).size, element, 1)
+
+#define cx_array_add(array, element) cx_array_add_a(cxDefaultAllocator, array, element)
+
+#define cx_array_insert_a(allocator, array, index, element) \
+        cx_array_insert_(allocator, (CxArray*)&(array), sizeof((array).data[0]), index, element, 1)
+
+#define cx_array_insert(array, index, element) cx_array_insert_a(cxDefaultAllocator, array, index, element)
 
 #define cx_array_insert_array_a(allocator, array, index, other, n) \
-        cx_array_insert_array_(allocator, (CxArray*)&(array), sizeof((array).data[0]), index, other, n)
+        cx_array_insert_(allocator, (CxArray*)&(array), sizeof((array).data[0]), index, other, n)
 
-#define cx_array_add_array(array, other, n) \
-        cx_array_insert_array_(cxDefaultAllocator, (CxArray*)&(array), sizeof((array).data[0]), (array).size, other, n)
+#define cx_array_insert_array(array, index, other, n) cx_array_insert_array_a(cxDefaultAllocator, array, index, other, n)
 
 #define cx_array_add_array_a(allocator, array, other, n) \
-        cx_array_insert_array_(allocator, (CxArray*)&(array), sizeof((array).data[0]), (array).size, other, n)
+        cx_array_insert_(allocator, (CxArray*)&(array), sizeof((array).data[0]), (array).size, other, n)
+
+#define cx_array_add_array(array, other, n) cx_array_add_array_a(cxDefaultAllocator, array, other, n)
+
+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);
+
+#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(array, cmp_func, element) cx_array_insert_sorted_a(cxDefaultAllocator, array, cmp_func, element)
+
+#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(array, cmp_func, sorted_data, n) cx_array_insert_sorted_array_a(cxDefaultAllocator, array, cmp_func, sorted_data, n)
+
+#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(array, cmp_func, element) cx_array_insert_unique_a(cxDefaultAllocator, array, cmp_func, element)
+
+#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(array, cmp_func, sorted_data, n) cx_array_insert_unique_array_a(cxDefaultAllocator, array, cmp_func, sorted_data, n)
 
 cx_attr_nodiscard cx_attr_nonnull
 CX_EXPORT CxIterator cx_array_iterator_(CxArray *array, size_t elem_size);
@@ -123,496 +154,7 @@
 
 #define cx_array_free_a(allocator, array) cx_array_free_(allocator, (CxArray*)&(array))
 
-/**
- * Declares variables for an array that can be used with the convenience macros.
- *
- * @par Examples
- * @code
- * // integer array with at most 255 elements
- * CX_ARRAY_DECLARE_SIZED(int, myarray, uint8_t)
- *
- * // array of MyObject* pointers where size and capacity are stored as unsigned int
- * CX_ARRAY_DECLARE_SIZED(MyObject*, objects, unsigned int)
- *
- * // initializing code
- * cx_array_initialize(myarray, 16); // reserve space for 16
- * cx_array_initialize(objects, 100); // reserve space for 100
- * @endcode
- *
- * @param type the type of the data
- * @param name the name of the array
- * @param size_type the type of the size (should be uint8_t, uint16_t, uint32_t, or size_t)
- *
- * @see cx_array_initialize()
- * @see cx_array_simple_copy()
- * @see cx_array_simple_add_sorted()
- * @see cx_array_simple_insert_sorted()
- */
-#define CX_ARRAY_DECLARE_SIZED(type, name, size_type) \
-    type * name; \
-    /** Array size. */ size_type name##_size; \
-    /** Array capacity. */ size_type name##_capacity
 
-/**
- * Declares variables for an array that can be used with the convenience macros.
- *
- * The size and capacity variables will have type @c size_t.
- * Use #CX_ARRAY_DECLARE_SIZED() to specify a different type.
- *
- * @par Examples
- * @code
- * // int array
- * CX_ARRAY_DECLARE(int, myarray)
- *
- * // initializing code
- * cx_array_initialize(myarray, 32); // reserve space for 32
- * @endcode
- *
- * @param type the type of the data
- * @param name the name of the array
- *
- * @see cx_array_initialize()
- * @see cx_array_simple_copy()
- * @see cx_array_simple_add_sorted()
- * @see cx_array_simple_insert_sorted()
- */
-#define CX_ARRAY_DECLARE(type, name) CX_ARRAY_DECLARE_SIZED(type, name, size_t)
-
-/**
- * Initializes an array with the given capacity.
- *
- * The type of the capacity depends on the type used during declaration.
- *
- * @par Examples
- * @code
- * CX_ARRAY_DECLARE_SIZED(int, arr1, uint8_t)
- * CX_ARRAY_DECLARE(int, arr2) // size and capacity are implicitly size_t
- *
- * // initializing code
- * cx_array_initialize(arr1, 500); // error: maximum for uint8_t is 255
- * cx_array_initialize(arr2, 500); // OK
- * @endcode
- *
- *
- * The memory for the array is allocated with the cxDefaultAllocator.
- *
- * @param array the name of the array
- * @param capacity the initial capacity
- * @see cx_array_initialize_a()
- * @see CX_ARRAY_DECLARE_SIZED()
- * @see CX_ARRAY_DECLARE()
- */
-#define cx_array_initialize(array, capacity) \
-        array##_capacity = capacity; \
-        array##_size = 0; \
-        array = cxMallocDefault(sizeof(array[0]) * capacity)
-
-/**
- * Initializes an array with the given capacity using the specified allocator.
- *
- * @par Example
- * @code
- * CX_ARRAY_DECLARE(int, myarray)
- *
- *
- * const CxAllocator *al = // ...
- * cx_array_initialize_a(al, myarray, 128);
- * // ...
- * cxFree(al, myarray); // remember to free with the same allocator
- * @endcode
- *
- * @param allocator (@c CxAllocator*) the allocator
- * @param array the name of the array
- * @param capacity the initial capacity
- * @see cx_array_initialize()
- * @see CX_ARRAY_DECLARE_SIZED()
- * @see CX_ARRAY_DECLARE()
- */
-#define cx_array_initialize_a(allocator, array, capacity) \
-        array##_capacity = capacity; \
-        array##_size = 0; \
-        array = cxMalloc(allocator, sizeof(array[0]) * capacity)
-
-/**
- * Defines a reallocation mechanism for arrays.
- * You can create your own, use cx_array_reallocator(), or
- * use the #cx_array_default_reallocator.
- */
-struct cx_array_reallocator_s {
-    /**
-     * Reallocates space for the given array.
-     *
-     * Implementations are not required to free the original array.
-     * This allows reallocation of static or stack memory by allocating heap memory
-     * and copying the array contents; namely when @c stack_ptr in this struct
-     * is not @c NULL and @p array equals @c stack_ptr.
-     *
-     * @param array the array to reallocate
-     * @param old_capacity the old number of elements
-     * @param new_capacity the new number of elements
-     * @param elem_size the size of each element
-     * @param alloc a reference to this allocator
-     * @return a pointer to the reallocated memory or @c NULL on failure
-     */
-    void *(*realloc)( void *array, size_t old_capacity, size_t new_capacity,
-            size_t elem_size, struct cx_array_reallocator_s *alloc);
-
-    /**
-     * The allocator that shall be used for the reallocations.
-     */
-    const CxAllocator *allocator;
-    /**
-     * Optional pointer to stack memory
-     * if the array is originally located on the stack.
-     */
-    const void *stack_ptr;
-};
-
-/**
- * Typedef for the array reallocator struct.
- */
-typedef struct cx_array_reallocator_s CxArrayReallocator;
-
-/**
- * A default array reallocator that is based on the cxDefaultAllocator.
- */
-CX_EXPORT extern CxArrayReallocator *cx_array_default_reallocator;
-
-/**
- * Creates a new array reallocator.
- *
- * When @p allocator is @c NULL, the cxDefaultAllocator will be used.
- *
- * When @p stack_ptr is not @c NULL, the reallocator is supposed to be used
- * @em only for the specific array initially located at @p stack_ptr.
- * When reallocation is needed, the reallocator checks if the array is
- * still located at @p stack_ptr and copies the contents to the heap.
- *
- * @note Invoking this function with both arguments being @c NULL will return a
- * reallocator that behaves like #cx_array_default_reallocator.
- *
- * @param allocator the allocator this reallocator shall be based on
- * @param stack_ptr the address of the array when the array is initially located
- * on the stack or shall not reallocate in place
- * @return an array reallocator
- */
-CX_EXPORT CxArrayReallocator cx_array_reallocator(
-        const struct cx_allocator_s *allocator, const void *stack_ptr);
-/**
- * Copies elements from one array to another.
- *
- * The elements are copied to the @p target array at the specified @p index,
- * overwriting possible elements. The @p index does not need to be in range of
- * the current array @p size. If the new index plus the number of elements added
- * extends the array's size, the remaining @p capacity is used.
- *
- * If the @p capacity is also insufficient to hold the new data, a reallocation
- * attempt is made with the specified @p reallocator.
- * You can create your own reallocator by hand, use #cx_array_default_reallocator,
- * or use the convenience function cx_array_reallocator() to create a custom reallocator.
- *
- * The @p width in bytes refers to the size and capacity.
- * Both must have the same width.
- * Supported are 0, 1, 2, and 4, as well as 8 if running on a 64-bit
- * architecture. If set to zero, the native word width is used.
- *
- * @note When this function does reallocate the array, it may allocate more
- * space than required to avoid further allocations in the near future.
- *
- * @param target a pointer to the target array
- * @param size a pointer to the size of the target array
- * @param capacity a pointer to the capacity of the target array
- * @param width the width in bytes for the @p size and @p capacity or zero for default
- * @param index the index where the copied elements shall be placed
- * @param src the source array
- * @param elem_size the size of one element
- * @param elem_count the number of elements to copy
- * @param reallocator the array reallocator to use
- * (@c NULL defaults to #cx_array_default_reallocator)
- * @retval zero success
- * @retval non-zero failure
- * @see cx_array_reallocator()
- */
-cx_attr_nonnull_arg(1, 2, 3, 6)
-CX_EXPORT int cx_array_copy(void **target, void *size, void *capacity, unsigned width,
-        size_t index, const void *src, size_t elem_size, size_t elem_count,
-        CxArrayReallocator *reallocator);
-
-/**
- * Convenience macro that uses cx_array_copy() with a default layout and
- * the specified reallocator.
- *
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param index (@c size_t) the index where the copied elements shall be placed
- * @param src (@c void*) the source array
- * @param count (@c size_t) the number of elements to copy
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_copy()
- */
-#define cx_array_simple_copy_a(reallocator, array, index, src, count) \
-    cx_array_copy((void**)&(array), &(array##_size), &(array##_capacity), \
-        sizeof(array##_size), index, src, sizeof((array)[0]), count, \
-        reallocator)
-
-/**
- * Convenience macro that uses cx_array_copy() with a default layout and
- * the default reallocator.
- *
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param index (@c size_t) the index where the copied elements shall be placed
- * @param src (@c void*) the source array
- * @param count (@c size_t) the number of elements to copy
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_copy_a()
- */
-#define cx_array_simple_copy(array, index, src, count) \
-    cx_array_simple_copy_a(NULL, array, index, src, count)
-
-/**
- * Inserts a sorted array into another sorted array.
- *
- * If either the target or the source array is not already sorted with respect
- * to the specified @p cmp_func, the behavior is undefined.
- *
- * If the capacity is insufficient to hold the new data, a reallocation
- * attempt is made.
- * You can create your own reallocator by hand, use #cx_array_default_reallocator,
- * or use the convenience function cx_array_reallocator() to create a custom reallocator.
- *
- * @param target a pointer to the target array
- * @param size a pointer to the size of the target array
- * @param capacity a pointer to the capacity of the target array
- * @param cmp_func the compare function for the elements
- * @param src the source array
- * @param elem_size the size of one element
- * @param elem_count the number of elements to insert
- * @param reallocator the array reallocator to use
- * (@c NULL defaults to #cx_array_default_reallocator)
- * @retval zero success
- * @retval non-zero failure
- */
-cx_attr_nonnull_arg(1, 2, 3, 5)
-CX_EXPORT int cx_array_insert_sorted(void **target, size_t *size, size_t *capacity,
-        cx_compare_func cmp_func, const void *src, size_t elem_size, size_t elem_count,
-        CxArrayReallocator *reallocator);
-
-/**
- * Inserts an element into a sorted array.
- *
- * If the target array is not already sorted with respect
- * to the specified @p cmp_func, the behavior is undefined.
- *
- * If the capacity is not enough to hold the new data, a reallocation
- * attempt is made.
- *
- * The \@ SIZE_TYPE is flexible and can be any unsigned integer type.
- * It is important, however, that @p size and @p capacity are pointers to
- * variables of the same type.
- *
- * @param target (@c void**) a pointer to the target array
- * @param size (@c SIZE_TYPE*) a pointer to the size of the target array
- * @param capacity (@c SIZE_TYPE*) a pointer to the capacity of the target array
- * @param elem_size (@c size_t) the size of one element
- * @param elem (@c void*) a pointer to the element to add
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @retval zero success
- * @retval non-zero failure
- */
-#define cx_array_add_sorted(target, size, capacity, elem_size, elem, cmp_func, reallocator) \
-    cx_array_insert_sorted((void**)(target), size, capacity, cmp_func, elem, elem_size, 1, reallocator)
-
-/**
- * Convenience macro for cx_array_add_sorted() with a default
- * layout and the specified reallocator.
- *
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param elem the element to add (NOT a pointer, address is automatically taken)
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_add_sorted()
- */
-#define cx_array_simple_add_sorted_a(reallocator, array, elem, cmp_func) \
-    cx_array_add_sorted(&array, &(array##_size), &(array##_capacity), \
-        sizeof((array)[0]), &(elem), cmp_func, reallocator)
-
-/**
- * Convenience macro for cx_array_add_sorted() with a default
- * layout and the default reallocator.
- *
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param elem the element to add (NOT a pointer, address is automatically taken)
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_add_sorted_a()
- */
-#define cx_array_simple_add_sorted(array, elem, cmp_func) \
-    cx_array_simple_add_sorted_a(NULL, array, elem, cmp_func)
-
-/**
- * Convenience macro for cx_array_insert_sorted() with a default
- * layout and the specified reallocator.
- *
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param src (@c void*) pointer to the source array
- * @param n (@c size_t) number of elements in the source array
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_insert_sorted()
- */
-#define cx_array_simple_insert_sorted_a(reallocator, array, src, n, cmp_func) \
-    cx_array_insert_sorted((void**)(&array), &(array##_size), &(array##_capacity), \
-        cmp_func, src, sizeof((array)[0]), n, reallocator)
-
-/**
- * Convenience macro for cx_array_insert_sorted() with a default
- * layout and the default reallocator.
- *
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param src (@c void*) pointer to the source array
- * @param n (@c size_t) number of elements in the source array
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_insert_sorted_a()
- */
-#define cx_array_simple_insert_sorted(array, src, n, cmp_func) \
-    cx_array_simple_insert_sorted_a(NULL, array, src, n, cmp_func)
-
-
-/**
- * Inserts a sorted array into another sorted array, avoiding duplicates.
- *
- * If either the target or the source array is not already sorted with respect
- * to the specified @p cmp_func, the behavior is undefined.
- *
- * If the capacity is insufficient to hold the new data, a reallocation
- * attempt is made.
- * You can create your own reallocator by hand, use #cx_array_default_reallocator,
- * or use the convenience function cx_array_reallocator() to create a custom reallocator.
- *
- * @param target a pointer to the target array
- * @param size a pointer to the size of the target array
- * @param capacity a pointer to the capacity of the target array
- * @param cmp_func the compare function for the elements
- * @param src the source array
- * @param elem_size the size of one element
- * @param elem_count the number of elements to insert
- * @param reallocator the array reallocator to use
- * (@c NULL defaults to #cx_array_default_reallocator)
- * @retval zero success
- * @retval non-zero failure
- */
-cx_attr_nonnull_arg(1, 2, 3, 5)
-CX_EXPORT int cx_array_insert_unique(void **target, size_t *size, size_t *capacity,
-        cx_compare_func cmp_func, const void *src, size_t elem_size, size_t elem_count,
-        CxArrayReallocator *reallocator);
-
-/**
- * Inserts an element into a sorted array if it does not exist.
- *
- * If the target array is not already sorted with respect
- * to the specified @p cmp_func, the behavior is undefined.
- *
- * If the capacity is insufficient to hold the new data, a reallocation
- * attempt is made.
- *
- * The \@ SIZE_TYPE is flexible and can be any unsigned integer type.
- * It is important, however, that @p size and @p capacity are pointers to
- * variables of the same type.
- *
- * @param target (@c void**) a pointer to the target array
- * @param size (@c SIZE_TYPE*) a pointer to the size of the target array
- * @param capacity (@c SIZE_TYPE*) a pointer to the capacity of the target array
- * @param elem_size (@c size_t) the size of one element
- * @param elem (@c void*) a pointer to the element to add
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @retval zero success (also when the element was already present)
- * @retval non-zero failure
- */
-#define cx_array_add_unique(target, size, capacity, elem_size, elem, cmp_func, reallocator) \
-    cx_array_insert_unique((void**)(target), size, capacity, cmp_func, elem, elem_size, 1, reallocator)
-
-/**
- * Convenience macro for cx_array_add_unique() with a default
- * layout and the specified reallocator.
- *
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param elem the element to add (NOT a pointer, address is automatically taken)
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_add_unique()
- */
-#define cx_array_simple_add_unique_a(reallocator, array, elem, cmp_func) \
-    cx_array_add_unique(&array, &(array##_size), &(array##_capacity), \
-        sizeof((array)[0]), &(elem), cmp_func, reallocator)
-
-/**
- * Convenience macro for cx_array_add_unique() with a default
- * layout and the default reallocator.
- *
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param elem the element to add (NOT a pointer, address is automatically taken)
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_add_unique_a()
- */
-#define cx_array_simple_add_unique(array, elem, cmp_func) \
-    cx_array_simple_add_unique_a(NULL, array, elem, cmp_func)
-
-/**
- * Convenience macro for cx_array_insert_unique() with a default
- * layout and the specified reallocator.
- *
- * @param reallocator (@c CxArrayReallocator*) the array reallocator to use
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param src (@c void*) pointer to the source array
- * @param n (@c size_t) number of elements in the source array
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_insert_unique()
- */
-#define cx_array_simple_insert_unique_a(reallocator, array, src, n, cmp_func) \
-    cx_array_insert_unique((void**)(&array), &(array##_size), &(array##_capacity), \
-        cmp_func, src, sizeof((array)[0]), n, reallocator)
-
-/**
- * Convenience macro for cx_array_insert_unique() with a default
- * layout and the default reallocator.
- *
- * @param array the name of the array (NOT a pointer or alias to the array)
- * @param src (@c void*) pointer to the source array
- * @param n (@c size_t) number of elements in the source array
- * @param cmp_func (@c cx_cmp_func) the compare function for the elements
- * @retval zero success
- * @retval non-zero failure
- * @see CX_ARRAY_DECLARE()
- * @see cx_array_simple_insert_unique_a()
- */
-#define cx_array_simple_insert_unique(array, src, n, cmp_func) \
-    cx_array_simple_insert_unique_a(NULL, array, src, n, cmp_func)
 
 /**
  * Searches the largest lower bound in a sorted array.

mercurial