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

Function algorithm_copy_if

algorithm/algorithm.c:1319–1335  ·  view source on GitHub ↗

* @brief Copies elements from a source array to a destination array if they satisfy a predicate function. * * @param first Pointer to the start of the source array. * @param last Pointer to the end of the source array. * @param size Size of each element in bytes. * @param result Pointer to the destination array. * @param pred Predicate function that determines if an element should be copied.

Source from the content-addressed store, hash-verified

1317 ALGORITHM_LOG("[algorithm_find_first_of] Success: Match found at index %zu in the main array.", i);
1318 return (void *)(ptr1 + i * size1);
1319 }
1320 }
1321 }
1322
1323 ALGORITHM_LOG("[algorithm_find_first_of] Info: No match found.");
1324 return NULL;
1325}
1326
1327
1328/**
1329 * @brief Performs a binary search to find the index of a value in a sorted range.
1330 *
1331 * This function performs a binary search on a sorted range `[base, base + num * size)` to find the index
1332 * of the value `val`. The range must be sorted according to the same comparison function `comp`.
1333 *
1334 * @param base Pointer to the start of the sorted array.
1335 * @param num Number of elements in the array.
1336 * @param size Size of each element in bytes.
1337 * @param val Pointer to the value to find.
1338 * @param comp Comparison function used to compare elements.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected