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

Function algorithm_equal

algorithm/algorithm.c:1064–1083  ·  view source on GitHub ↗

* @brief Checks if two ranges are equal. * * This function compares two ranges `[base1, base1 + num1 * size1)` and `[base2, base2 + num2 * size2)` * to determine if they contain the same elements in the same order, as determined by the comparison function `comp`. * * @param base1 Pointer to the start of the first array. * @param num1 Number of elements in the first array. * @param size1 Siz

Source from the content-addressed store, hash-verified

1062 size_t run = 1;
1063 if (tmp) {
1064 run = STB_RUN;
1065 for (size_t i = 0; i < num; i += run) {
1066 pdq_insertion(a + i * size, (num - i < run) ? num - i : run, size, comp, tmp, 1);
1067 }
1068 }
1069 for (size_t width = run; width < num; width *= 2) {
1070 for (size_t i = 0; i < num; ) {
1071 size_t mid = i + ((width < num - i) ? width : num - i);
1072 size_t end = mid + ((width < num - mid) ? width : num - mid);
1073 alg_merge_no_buffer(a + i * size, mid - i, end - mid, size, comp);
1074 i = end;
1075 }
1076 }
1077 }
1078 if (tmp && tmp != (char *)stk.bytes) {
1079 free(tmp);
1080 }
1081 ALGORITHM_LOG("[algorithm_stable_sort] Stable sort completed.");
1082}
1083
1084
1085/**
1086 * @brief Sorts an array; the sort is STABLE: elements that compare equal keep

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected