dp_16's blog

By dp_16, history, 7 months ago, In English

If we have struct like this:

struct Example{
    int first, second;
    bool operator<(const Example &another) const {
        if(first==another.first)return second>another.second;
        return first>another.first;
    }
};

In other words, struct which has two integer variables first, second. Same as standard pair<int, int> variable but is difference in how will it be sorted in some data structure (vector, map...)

Could there be increase in TC if we talk about sorting when inserting simpler variables inside of maps, sets etc.? (simple variables — where the code inside operator would be O(1). Like in the example).

Full text and comments »

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