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

Function algorithm_find_first_of

algorithm/algorithm.c:442–459  ·  view source on GitHub ↗

* @brief Finds the first element in a range that matches any element in another range. * * This function searches for the first element in the range `[base1, base1 + num1 * size1)` that matches * any element in the range `[base2, base2 + num2 * size2)`. * * @param base1 Pointer to the start of the main array. * @param num1 Number of elements in the main array. * @param size1 Size of each el

Source from the content-addressed store, hash-verified

440 }
441 if (tmp) {
442 alg_copy_elem(a + i * sz, tmp, sz);
443 }
444}
445
446/* Heapsort: introsort's O(n log n) fallback (and the whole sort when there
447 * is no memory for a scratch element). */
448static void pdq_heapsort(char *a, size_t n, size_t sz, AlgorithmCompareFunc comp, char *tmp) {
449 for (size_t i = n / 2; i > 0; ) {
450 --i;
451 pdq_sift_down(a, i, n, sz, comp, tmp);
452 }
453 for (size_t end = n; end > 1; ) {
454 --end;
455 alg_swap_bytes(a, a + end * sz, sz);
456 pdq_sift_down(a, 0, end, sz, comp, tmp);
457 }
458}
459
460ALG_INLINE void pdq_sort2(char *x, char *y, size_t sz, AlgorithmCompareFunc comp) {
461 if (comp(y, x) < 0) {
462 alg_swap_bytes(x, y, sz);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected