MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / verify_full

Function verify_full

examples/sort/bench_stable_sort.cpp:206–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204
205template <typename T>
206bool verify_full(const std::vector<T> & out, const std::vector<T> & in) {
207 size_t n = out.size();
208 if (in.size() != n) return false;
209 std::vector<char> seen(n, 0);
210 for (size_t i = 0; i < n; i++) {
211 int32_t ix = idx_of(out[i]);
212 if (ix < 0 || size_t(ix) >= n || seen[ix]) return false; // permutation
213 seen[ix] = 1;
214 if (key_of(out[i]) != key_of(in[size_t(ix)])) return false; // element integrity
215 if (i && key_of(out[i]) < key_of(out[i-1])) return false; // sorted
216 if (i && key_of(out[i]) == key_of(out[i-1]) && idx_of(out[i]) < idx_of(out[i-1])) return false; // stable
217 }
218 return true;
219}
220
221// ============================================================================
222// Input patterns. idx is always the original position (0..n-1).

Callers 2

bench_oneFunction · 0.85
correctness_sweepFunction · 0.85

Calls 3

idx_ofFunction · 0.85
key_ofFunction · 0.70
sizeMethod · 0.45

Tested by

no test coverage detected