# HG changeset patch # User Mike Becker # Date 1744560089 -7200 # Node ID a8d86a951d0be2556b4fc85e92292a953e1ba9ad # Parent 1e7ee17777f4fd0c46e3011997a27b996307f9b1 adds cxListContains() implementation (still needs test and docu) diff -r 1e7ee17777f4 -r a8d86a951d0b src/cx/list.h --- 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