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

Function algorithm_replace

algorithm/algorithm.c:2147–2167  ·  view source on GitHub ↗

* Replaces occurrences of a value in an array. * * This function replaces occurrences of the value `old_val` with the value `new_val` in the array `base`. * The number of elements in the array is specified by `num`, and the size of each element is specified by `size`. * The comparison function `comp` is used to compare elements in the array. * * @param base Pointer to the start of the ar

Source from the content-addressed store, hash-verified

2145 }
2146 } while (!pred(last));
2147
2148 ALGORITHM_LOG("[algorithm_partition] Info: Swapping elements.");
2149 swap(first, last, size);
2150 first += size;
2151 }
2152
2153 ALGORITHM_LOG("[algorithm_partition] Success: Partitioning completed.");
2154 return first;
2155}
2156
2157
2158/**
2159 * @brief Generates values for a range using a generator function.
2160 *
2161 * @param first Pointer to the start of the range.
2162 * @param last Pointer to the end of the range.
2163 * @param size Size of each element in bytes.
2164 * @param gen Generator function that produces values.
2165 */
2166void algorithm_generate(void *first, void *last, size_t size, GeneratorFunc gen) {
2167 ALGORITHM_LOG("[algorithm_generate] Info: Generating values for range.");
2168
2169 char *current = (char *)first;
2170 while (current != last) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected