MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / algorithm_equal_range

Function algorithm_equal_range

algorithm/algorithm.c:1383–1393  ·  view source on GitHub ↗

* @brief Finds the range of elements that are equal to a specified value in a sorted range. * * This function returns a `Pair` representing the range of elements in the sorted array `base` * that are equal to the value `val`, as determined by the comparison function `comp`. The * `first` element in the `Pair` is the first element in the range, and the `second` element * is one past the last e

Source from the content-addressed store, hash-verified

1381 * @param comp Comparison function used to compare elements.
1382 * It should return a negative value if the first element is less than the second,
1383 * zero if they are equal, and a positive value if the first element is greater than the second.
1384 *
1385 * @return Pointer to the maximum element, or `NULL` if the array is empty.
1386 */
1387void *algorithm_max_element(const void *base, size_t num, size_t size, CompareFunc comp) {
1388 if (num == 0) {
1389 ALGORITHM_LOG("[algorithm_max_element] Error: Array is empty, returning NULL.");
1390 return NULL;
1391 }
1392 ALGORITHM_LOG("[algorithm_max_element] Info: Searching for the maximum element in an array of %zu elements.", num);
1393
1394 const char *max_element = (const char *)base;
1395 for (size_t i = 1; i < num; ++i) {
1396 const char *element = (const char *)base + i * size;

Callers

nothing calls this directly

Calls 2

algorithm_lower_boundFunction · 0.85
algorithm_upper_boundFunction · 0.85

Tested by

no test coverage detected