36std::vector<Factor_>
clean_factor(std::size_t n,
const Factor_* factor, Output_* cleaned) {
38 std::unordered_map<Factor_, Output_> mapping;
39 for (
decltype(n) i = 0; i < n; ++i) {
40 auto current = factor[i];
41 auto mIt = mapping.find(current);
42 if (mIt != mapping.end()) {
43 cleaned[i] = mIt->second;
45 Output_ alt = mapping.size();
46 mapping[current] = alt;
50 return std::vector<std::pair<Factor_, Output_> >(mapping.begin(), mapping.end());
54 std::sort(unique.begin(), unique.end());
55 auto nuniq = unique.size();
56 auto remapping = sanisizer::create<std::vector<Output_> >(nuniq);
57 auto output = sanisizer::create<std::vector<Factor_> >(nuniq);
58 for (
decltype(nuniq) u = 0; u < nuniq; ++u) {
59 remapping[unique[u].second] = u;
60 output[u] = unique[u].first;
64 for (
decltype(n) i = 0; i < n; ++i) {
65 cleaned[i] = remapping[cleaned[i]];