STL中set、map的比较函数
2010-08-14 22:52
495 查看
1.如果比较元素不是结构体,重载()符号:
2.如果是结构体,则把比较函数内部,重载<符号:
/** * setCmp,自定义set排序函数。重载"()"操作符 */ struct setCmp { bool operator()(const int& a, const int& b) { return a < b; } };
2.如果是结构体,则把比较函数内部,重载<符号:
struct Info { string name; float score; //重载“<” bool operator<(const Info &a) const { return a.score < score; } };
相关文章推荐
- STL中sort、priority_queue、map、set的自定义比较函数
- STL中sort、priority_queue、map、set的自定义比较函数
- STL set,map , priority_queue 及 lower_bound 的排序比较函数
- STL中sort、priority_queue、map、set的自定义比较函数
- 定义自己的STL map key的类型和比较函数
- stl中map自定义比较函数
- 用自己的比较函数构造STL的set
- STL中的容器使用比较(string vector list deque set map)
- map及set中自定义比较函数
- STL 笔记(二) 关联容器 map、set、multimap 和 multimap常用函数
- C++STL(vector,map,set,list)成员函数整理
- STL中map的比较函数
- STL源码:map、set与其他顺序容器的一些比较
- stl中map自定义比较函数
- STL之std::set、std::map的lower_bound和upper_bound函数使用说明
- stl::map的比较函数(less, <)
- STL之std::set、std::map的lower_bound和upper_bound函数使用说明
- STL中比较常用的容器是vector,set和map,比较常用的算法有Sort等。
- c++ 提高4 map容器 共性机制 使用时机 比较| STL算法 算法基础仿函数 谓词 函数适配器 遍历算法
- C++ list, vector, map, set 区别与用法比较