mirror of
https://github.com/VectorCamp/vectorscan.git
synced 2025-06-28 16:41:01 +03:00
container: allow sort_and_unique to have a comparator
This commit is contained in:
parent
cea8f452f2
commit
dc50ab291b
@ -3658,13 +3658,11 @@ void makeRoleInfixTriggers(RoseBuildImpl &build, build_context &bc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Order, de-dupe and add instructions to the end of program.
|
// Order, de-dupe and add instructions to the end of program.
|
||||||
sort(begin(infix_program), end(infix_program),
|
sort_and_unique(infix_program, [](const RoseInstrTriggerInfix &a,
|
||||||
[](const RoseInstrTriggerInfix &a, const RoseInstrTriggerInfix &b) {
|
const RoseInstrTriggerInfix &b) {
|
||||||
return tie(a.cancel, a.queue, a.event) <
|
return tie(a.cancel, a.queue, a.event) <
|
||||||
tie(b.cancel, b.queue, b.event);
|
tie(b.cancel, b.queue, b.event);
|
||||||
});
|
});
|
||||||
infix_program.erase(unique(begin(infix_program), end(infix_program)),
|
|
||||||
end(infix_program));
|
|
||||||
for (const auto &ri : infix_program) {
|
for (const auto &ri : infix_program) {
|
||||||
program.add_before_end(make_unique<RoseInstrTriggerInfix>(ri));
|
program.add_before_end(make_unique<RoseInstrTriggerInfix>(ri));
|
||||||
}
|
}
|
||||||
@ -4163,13 +4161,10 @@ void makePushDelayedInstructions(const RoseBuildImpl &build,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort(begin(delay_instructions), end(delay_instructions),
|
sort_and_unique(delay_instructions, [](const RoseInstrPushDelayed &a,
|
||||||
[](const RoseInstrPushDelayed &a, const RoseInstrPushDelayed &b) {
|
const RoseInstrPushDelayed &b) {
|
||||||
return tie(a.delay, a.index) < tie(b.delay, b.index);
|
return tie(a.delay, a.index) < tie(b.delay, b.index);
|
||||||
});
|
});
|
||||||
delay_instructions.erase(
|
|
||||||
unique(begin(delay_instructions), end(delay_instructions)),
|
|
||||||
end(delay_instructions));
|
|
||||||
|
|
||||||
for (const auto &ri : delay_instructions) {
|
for (const auto &ri : delay_instructions) {
|
||||||
program.add_before_end(make_unique<RoseInstrPushDelayed>(ri));
|
program.add_before_end(make_unique<RoseInstrPushDelayed>(ri));
|
||||||
|
@ -90,9 +90,9 @@ auto make_vector_from(const std::pair<It, It> &range)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Sort a sequence container and remove duplicates. */
|
/** \brief Sort a sequence container and remove duplicates. */
|
||||||
template <typename C>
|
template <typename C, typename Compare = std::less<typename C::value_type>>
|
||||||
void sort_and_unique(C &container) {
|
void sort_and_unique(C &container, Compare comp = Compare()) {
|
||||||
std::sort(std::begin(container), std::end(container));
|
std::sort(std::begin(container), std::end(container), comp);
|
||||||
container.erase(std::unique(std::begin(container), std::end(container)),
|
container.erase(std::unique(std::begin(container), std::end(container)),
|
||||||
std::end(container));
|
std::end(container));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user