Created
August 22, 2018 14:29
-
-
Save pk13610/0e1262003488f78ca557aa68cc82e8e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <set> | |
#include <iostream> | |
struct MyStruct | |
{ | |
int kk; | |
bool operator<(const MyStruct & right) const | |
{ | |
return kk > right.kk; | |
} | |
}; | |
struct MyStructCmp | |
{ | |
bool operator()(const MyStruct& left, const MyStruct& right) | |
{ | |
return left.kk > right.kk; | |
} | |
}; | |
int main(int argc, char* argv[]) | |
{ | |
//std::set<MyStruct> ss; | |
std::set<MyStruct, MyStructCmp> ss; | |
for (int i = 0; i < 100; i++) | |
{ | |
MyStruct ms; | |
ms.kk = i; | |
ss.insert(ms); | |
} | |
for (auto it=ss.begin(); it != ss.end(); ++it) | |
{ | |
std::cout << it->kk << std::endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment