stl 学习笔记
2014-12-01 00:00
423 查看
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; }
相关文章推荐
- STL学习笔记一(深入VC之STL系列)
- STL学习笔记二(仿函式)
- stl 学习笔记 8 续 (function object)
- STL容器--学习笔记
- stl 学习笔记 12
- stl 学习笔记 11
- [原创]STL Iterator,traits学习笔记
- 数据结构-STL模板-学习笔记
- stl学习笔记7
- STL的内观排序(introsort)算法学习笔记
- STL学习笔记,关于iterator的实现细节
- stl学习笔记2(容器,函数对象)
- STL学习笔记(二):STL对待错误的态度
- STL学习笔记1—概述
- stl学习笔记3
- C++精华(STL)学习笔记之算法
- STL学习笔记:用非递归的方法实现汉诺塔问题
- STL学习笔记(三):STL的可扩展性
- stl 学习笔记 10
- STL学习笔记(二)