wise guys
My question was like this:
I need to use priority_queue from std, everything works fine, until if there exists ties between my records, the order is no long consistent if I compile using clang compared to compiling on gcc.
my comparator function is simple:
bool comparator(const max_pair_t &lhs, const max_pair_t &rhs) {
return lhs.pval < rhs.pval;
}
that's it.
Is there a way to resolve this problem?
PS: I printed out all the records using two binary excutables, and compared the order side by side, the order is different, but the tied records are in the neighboring area
std::priority_queue
gives no guarantees about sort stability. If you need sort stability, you'll have to provide it yourself, e.g. by storing a progressively increasing or decreasing value (doesn't really matter which, it just changes the direction of the fallback comparison) that is used when the primary comparison key is equal, and stripping it off when you pop off the queue.