MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / set_intersect

Function set_intersect

cp-profiler/src/cpprofiler/analysis/path_comp.cpp:12–26  ·  view source on GitHub ↗

A wrapper around std::set_intersection; copying is intended

Source from the content-addressed store, hash-verified

10
11/// A wrapper around std::set_intersection; copying is intended
12static vector<Label> set_intersect(vector<Label> v1, vector<Label> v2)
13{
14 /// set_intersection requires the resulting set to be
15 /// at least as large as the smallest of the two sets
16 vector<Label> res(std::min(v1.size(), v2.size()));
17
18 std::sort(begin(v1), end(v1));
19 std::sort(begin(v2), end(v2));
20
21 auto it = std::set_intersection(begin(v1), end(v1), begin(v2), end(v2),
22 begin(res));
23 res.resize(it - begin(res));
24
25 return res;
26}
27
28/// A wrapper around std::set_symemtric_diff; copying is intended
29static vector<Label> set_symmetric_diff(vector<Label> v1, vector<Label> v2)

Callers 1

getLabelDiffFunction · 0.85

Calls 2

sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected