stl 学习笔记
来源:互联网 发布:网络拓扑生成工具 编辑:程序博客网 时间:2024/05/18 00:35
set用法:
#include <set>class Test {public: Test(int a,int b) { this->a = a; this->b = b; } bool operator < (const Test &t)const { return b < t.b; } int a; int b;};void test_set_compare() { std::set<Test> test; test.insert(Test(3,2)); test.insert(Test(5,5)); test.insert(Test(1,9)); test.insert(Test(6,1)); std::set<Test>::const_iterator iter_test; for (iter_test = test.begin(); iter_test != test.end(); ++iter_test) { std::cout << iter_test->a << "," << iter_test->b << std::endl; }}int main() { test_set_compare(); return 0;}