Pagini recente » Diferente pentru blog/combinatorics-shortlist intre reviziile 3 si 4 | Diferente pentru blog/combinatorics-shortlist intre reviziile 2 si 3 | Diferente pentru blog/combinatorics-shortlist intre reviziile 4 si 5 | Diferente pentru blog/cpp11 intre reviziile 46 si 45 | Diferente pentru blog/cpp11 intre reviziile 38 si 37
Diferente pentru
blog/cpp11 intre reviziile
#38 si
#37
Nu exista diferente intre titluri.
Diferente intre continut:
s.insert(v);
==
You don't need to worry about collisions, $unordered_set$ and $unordered_map$ will take care of them for you.
h3. 5. lambda functions
You can now define anonymous functions to write less code. A common application is sorting according to multiple criteria.
== code(cpp) |
#include <algorithm>
using namespace std;
...
vector<int> a = {5, 3, 1, 3};
vector<int> b = {6, 1, 7, 2};
vector<int> indexes = {0, 1, 2, 3};
sort(indexes.begin(), indexes.end(), [&a, &b](int x, int y) -> bool {
return a[x] < a[y] || (a[x] == a[y] && b[x] < b[y]);
});
==
(Often, a cleaner alternative to lambda functions is defining a class holding all the data needed for sorting and providing an implementation for the $<$ operator.)
You don't need to worry about collisions, $unordered_set$ and $unordered_map$ will take care of that for you.
Nu exista diferente intre securitate.
Topicul de forum nu a fost schimbat.