cvector · Section 3
cvector_find
NAME
cvector_find - find the index of the first occurrence of an element
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cvector.h>
size_t cvector_find(cvec v, const void *elem,
ccol_comparison_proc cmp);
DESCRIPTION
Scans the vector linearly and returns the zero-based index of the first element equal to *elem. With a NULL cmp the elements are compared with memcmp over the element size, that is byte by byte.
PARAMETERS
v Vector to search (must not be NULL)
elem Pointer to the value to search for
cmp Comparison function (int(*)(const void*,const void*)), or NULL
to use memcmp
RETURN VALUE
Zero-based index of the first element that matches. ccol_invalid_size when there is no match, and when elem is NULL.
NOTES
O(n). Asserts if v is NULL. With a NULL cmp, structs with padding bytes may not compare correctly.