src/ucx/cx/array_list.h

changeset 490
d218607f5a7e
parent 438
22eca559aded
--- a/src/ucx/cx/array_list.h	Sat Mar 25 17:18:51 2023 +0100
+++ b/src/ucx/cx/array_list.h	Fri May 05 18:02:11 2023 +0200
@@ -101,9 +101,10 @@
  * 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 index must be in range of the current
- * array \p size. If the number of elements added would extend the array's size,
- * and \p capacity is not \c NULL, the remaining capacity is used.
+ * 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
+ * would extend the array's size, and \p capacity is not \c NULL, the remaining
+ * capacity is used.
  *
  * If the capacity is insufficient to hold the new data, a reallocation
  * attempt is made, unless the allocator is set to \c NULL, in which case
@@ -151,19 +152,40 @@
 /**
  * Allocates an array list for storing elements with \p item_size bytes each.
  *
+ * If \p item_size is CX_STORE_POINTERS, the created list will be created as if
+ * cxListStorePointers() was called immediately after creation.
+ *
  * @param allocator the allocator for allocating the list memory
+ * (if \c NULL the cxDefaultAllocator will be used)
  * @param comparator the comparator for the elements
+ * (if \c NULL sort and find functions will not work)
  * @param item_size the size of each element in bytes
  * @param initial_capacity the initial number of elements the array can store
  * @return the created list
  */
 CxList *cxArrayListCreate(
         CxAllocator const *allocator,
-        CxListComparator comparator,
+        cx_compare_func comparator,
         size_t item_size,
         size_t initial_capacity
-) __attribute__((__nonnull__));
+);
 
+/**
+ * Allocates an array list for storing elements with \p item_size bytes each.
+ *
+ * The list will use the cxDefaultAllocator and \em NO compare function.
+ * If you want to call functions that need a compare function, you have to
+ * set it immediately after creation or use cxArrayListCreate().
+ *
+ * If \p item_size is CX_STORE_POINTERS, the created list will be created as if
+ * cxListStorePointers() was called immediately after creation.
+ *
+ * @param item_size the size of each element in bytes
+ * @param initial_capacity the initial number of elements the array can store
+ * @return the created list
+ */
+#define cxArrayListCreateSimple(item_size, initial_capacity) \
+    cxArrayListCreate(NULL, NULL, item_size, initial_capacity)
 
 #ifdef __cplusplus
 } // extern "C"

mercurial