adds cxListContains() implementation (still needs test and docu)

Sun, 13 Apr 2025 18:01:29 +0200

author
Mike Becker <universe@uap-core.de>
date
Sun, 13 Apr 2025 18:01:29 +0200
changeset 1293
a8d86a951d0b
parent 1292
1e7ee17777f4
child 1294
30d7ae76c76a

adds cxListContains() implementation (still needs test and docu)

src/cx/list.h file | annotate | diff | comparison | revisions
--- a/src/cx/list.h	Sun Apr 13 14:56:05 2025 +0200
+++ b/src/cx/list.h	Sun Apr 13 18:01:29 2025 +0200
@@ -860,6 +860,7 @@
  * @param elem the element to find
  * @return the index of the element or the size of the list when the element is not found
  * @see cxListIndexValid()
+ * @see cxListContains()
  */
 cx_attr_nonnull
 cx_attr_nodiscard
@@ -871,6 +872,26 @@
 }
 
 /**
+ * Checks, if the list contains the specified element.
+ *
+ * The elements are compared with the list's comparator function.
+ *
+ * @param list the list
+ * @param elem the element to find
+ * @retval true if the element is contained
+ * @retval false if the element is not contained
+ * @see cxListFind()
+ */
+cx_attr_nonnull
+cx_attr_nodiscard
+static inline bool cxListContains(
+    const CxList* list,
+    const void* elem
+) {
+    return list->cl->find_remove((CxList*)list, elem, false) < list->collection.size;
+}
+
+/**
  * Checks if the specified index is within bounds.
  *
  * @param list the list

mercurial