src/cx/list.h

changeset 1477
9170a7dff573
parent 1468
0f4d90a1ae23
--- a/src/cx/list.h	Fri Nov 07 18:42:06 2025 +0100
+++ b/src/cx/list.h	Fri Nov 07 19:13:28 2025 +0100
@@ -978,6 +978,7 @@
  * @param data optional additional data that is passed to the clone function
  * @retval zero when all elements were successfully cloned
  * @retval non-zero when an allocation error occurred
+ * @see cxListUnion()
  */
 cx_attr_nonnull_arg(1, 2, 3)
 CX_EXPORT int cxListClone(CxList *dst, const CxList *src,
@@ -1009,8 +1010,8 @@
 /**
  * Clones elements from a list only if they are also present in another list.
  *
- * This function is optimized for the case when both the @p minuend and the
- * @p subtrahend are sorted.
+ * This function is optimized for the case when both the @p src and the
+ * @p other list are sorted.
  *
  * If the destination list already contains elements, the intersection is appended
  * to that list.
@@ -1028,6 +1029,32 @@
 CX_EXPORT int cxListIntersection(CxList *dst, const CxList *src, const CxList *other,
         cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
 
+/**
+ * Performs a deep clone of one list into another, skipping duplicates.
+ *
+ * This function is optimized for the case when both the @p src and the
+ * @p other list are sorted.
+ * In that case, the union will also be sorted.
+ *
+ * If the destination list already contains elements, the union is appended
+ * to that list. In that case the destination is not necessarily sorted.
+ *
+ * @param dst the destination list
+ * @param src the primary source list
+ * @param other the other list, where elements are only cloned from
+ * when they are not in @p src
+ * @param clone_func the clone function for the elements
+ * @param clone_allocator the allocator that is passed to the clone function
+ * @param data optional additional data that is passed to the clone function
+ * @retval zero when the elements were successfully cloned
+ * @retval non-zero when an allocation error occurred
+ * @see cxListClone()
+ */
+cx_attr_nonnull_arg(1, 2, 3, 4)
+CX_EXPORT int cxListUnion(CxList *dst, const CxList *src, const CxList *other,
+        cx_clone_func clone_func, const CxAllocator *clone_allocator, void *data);
+
+
 #ifdef __cplusplus
 } // extern "C"
 #endif

mercurial