Doubt with Maps, Sets with Custom Structs

Правка en1, от dp_16, 2024-04-30 15:55:45

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).

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский dp_16 2024-04-30 16:00:55 6
en4 Английский dp_16 2024-04-30 15:59:13 1 Tiny change: '\n }\n}\n~~~~~\n\' -> '\n }\n};\n~~~~~\n\'
en3 Английский dp_16 2024-04-30 15:58:16 1
en2 Английский dp_16 2024-04-30 15:57:49 7
en1 Английский dp_16 2024-04-30 15:55:45 702 Initial revision (published)