diff -r d4385f35f8b0 -r ef7cab6eb131 docs/Writerside/topics/array_list.h.md --- a/docs/Writerside/topics/array_list.h.md Tue Dec 16 21:33:58 2025 +0100 +++ b/docs/Writerside/topics/array_list.h.md Wed Dec 17 19:05:50 2025 +0100 @@ -175,6 +175,18 @@ size_t cx_array_binary_search_sup( const void *arr, size_t size, size_t elem_size, const void *elem, cx_compare_func cmp_func); + +size_t cx_array_binary_search_c( + const void *arr, size_t size, size_t elem_size, + const void *elem, cx_compare_func2 cmp_func, void *context); + +size_t cx_array_binary_search_inf_c( + const void *arr, size_t size, size_t elem_size, + const void *elem, cx_compare_func2 cmp_func, void *context); + +size_t cx_array_binary_search_sup_c( + const void *arr, size_t size, size_t elem_size, + const void *elem, cx_compare_func2 cmp_func, void *context); ``` The function `cx_array_binary_search()` searches the array `arr` for the data pointed to by `elem` using the compare function `cmp_func`. @@ -194,9 +206,11 @@ the binary search and the infimum report the largest index and the supremum reports the smallest index of the identical items, respectively. +The function variants with the `_c` suffix allow additional `context` for the compare function. + > Note that all the above functions are only well-defined on arrays which are sorted with respect to the given compare function. > -> This can, for example, easily be achieved by calling the standard library's `qsort()` function. +> This can, for example, easily be achieved by calling the standard library's `qsort()` or `qsort_s()` function. >{style="note"} > Despite the name, neither C nor POSIX standards require the standard library's `bsearch()` function to be implemented using binary search.