* @brief Finds the first occurrence of two consecutive elements that are equal. * * This function searches through the array pointed to by `base` and finds the first pair of consecutive * elements that are equal, as determined by the comparison function `comp`. * * @param base Pointer to the start of the array. * @param num Number of elements in the array. * @param size Size of each elemen
| 1798 | } |
| 1799 | b += (comp(b, val) < 0) ? size : 0; |
| 1800 | return (void *)b; |
| 1801 | } |
| 1802 | size_t low = 0; |
| 1803 | size_t high = num; |
| 1804 | while (low < high) { |
| 1805 | size_t mid = low + (high - low) / 2; |
| 1806 | if (comp(b + mid * size, val) < 0) { |
| 1807 | low = mid + 1; |
| 1808 | } |
| 1809 | else { |
| 1810 | high = mid; |
| 1811 | } |
| 1812 | } |
| 1813 | |
| 1814 | ALGORITHM_LOG("[algorithm_lower_bound] Success: Found lower bound at index %zu.", low); |
| 1815 | return (void *)(b + low * size); |
| 1816 | } |
| 1817 | |
| 1818 | |
| 1819 | /** |
| 1820 | * @brief Finds the first position in a sorted range where a value is greater than a specified value. |
| 1821 | * |
| 1822 | * This function performs a binary search on a sorted range `[base, base + num * size)` to find the first |
nothing calls this directly
no outgoing calls
no test coverage detected