33std::vector<Factor_>
clean_factor(
size_t n,
const Factor_* factor, Output_* cleaned) {
35 std::unordered_map<Factor_, Output_> mapping;
36 for (
size_t i = 0; i < n; ++i) {
37 auto current = factor[i];
38 auto mIt = mapping.find(current);
39 if (mIt != mapping.end()) {
40 cleaned[i] = mIt->second;
42 Output_ alt = mapping.size();
43 mapping[current] = alt;
47 return std::vector<std::pair<Factor_, Output_> >(mapping.begin(), mapping.end());
51 std::sort(unique.begin(), unique.end());
52 size_t nuniq = unique.size();
53 std::vector<Output_> remapping(nuniq);
54 std::vector<Factor_> output(nuniq);
55 for (
size_t u = 0; u < nuniq; ++u) {
56 remapping[unique[u].second] = u;
57 output[u] = unique[u].first;
61 for (
size_t i = 0; i < n; ++i) {
62 cleaned[i] = remapping[cleaned[i]];