Giant_on_weed's blog

By Giant_on_weed, history, 2 years ago, In English

I tried to make a set out of this struct and it gives compilation error

struct triplet{
    int first;
    int second;
    int index;
    bool operator < (const triplet &A){
        if(first==A.first)return second < A.second;
        return first < A.first;
    }
};

The operator works while simple sorting but is giving error while implementing sets, maps and priority_queues.

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By Giant_on_weed, history, 2 years ago, In English

I am just curious if there will be a problem if I don't if I keep PBDS code uncommented in my template. Can it cause slow execution time or something like that? Also, in case if anyone knows, why isn't ordered set already included in C++ STL library, it there some problems it can cause in real world applications?

Full text and comments »

  • Vote: I like it
  • +14
  • Vote: I do not like it