ucx/cx/collection.h

changeset 113
dde28a806552
parent 112
c3f2f16fa4b8
--- a/ucx/cx/collection.h	Sun Oct 19 21:20:08 2025 +0200
+++ b/ucx/cx/collection.h	Mon Nov 10 21:52:51 2025 +0100
@@ -151,7 +151,15 @@
  * @retval true if the elements are currently sorted wrt. the collection's compare function
  * @retval false if the order of elements is unknown
  */
-#define cxCollectionSorted(c) ((c)->collection.sorted)
+#define cxCollectionSorted(c) ((c)->collection.sorted || (c)->collection.size == 0)
+
+/**
+ * Sets the compare function for a collection.
+ *
+ * @param c a pointer to a struct that contains #CX_COLLECTION_BASE
+ * @param func (@c cx_compare_func) the compare function that shall be used by @c c
+ */
+#define cxCollectionCompareFunc(c, func) (c)->collection.cmpfunc = (func)
 
 /**
  * Sets a simple destructor function for this collection.

mercurial