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

Function algorithm_remove_copy

algorithm/algorithm.c:2077–2094  ·  view source on GitHub ↗

* @brief Copies elements from a source array to a destination array, excluding elements that match a given value. * * @param source Pointer to the source array. * @param num Number of elements in the source array. * @param size Size of each element in bytes. * @param result Pointer to the destination array. * @param val Pointer to the value to exclude. * @param comp Comparison function used

Source from the content-addressed store, hash-verified

2075 }
2076
2077 char *i = (char *)last - size;
2078 while (i != (char *)first) {
2079 char *j = i;
2080 i -= size;
2081
2082 if (comp(j, i)) {
2083 char *k = (char *)last - size;
2084
2085 while (!comp(k, i)) {
2086 k -= size;
2087 }
2088
2089 ALGORITHM_LOG("[algorithm_prev_permutation] Info: Swapping elements.");
2090 swap(i, k, size);
2091 reverse(j, last, size);
2092
2093 ALGORITHM_LOG("[algorithm_prev_permutation] Success: Previous permutation generated.");
2094 return true;
2095 }
2096 if (i == (char *)first) {
2097 ALGORITHM_LOG("[algorithm_prev_permutation] Info: Resetting to largest permutation.");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected