MCPcopy Create free account
hub / github.com/dendibakh/perf-ninja / compare

Function compare

labs/core_bound/function_inlining_1/solution.cpp:6–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include <stdlib.h>
5
6static int compare(const void *lhs, const void *rhs) {
7 auto &a = *reinterpret_cast<const S *>(lhs);
8 auto &b = *reinterpret_cast<const S *>(rhs);
9
10 if (a.key1 < b.key1)
11 return -1;
12
13 if (a.key1 > b.key1)
14 return 1;
15
16 if (a.key2 < b.key2)
17 return -1;
18
19 if (a.key2 > b.key2)
20 return 1;
21
22 return 0;
23}
24
25void solution(std::array<S, N> &arr) {
26 qsort(arr.data(), arr.size(), sizeof(S), compare);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected