仿函数1-当排序规则
来源:互联网 发布:林俊杰 知乎 编辑:程序博客网 时间:2024/05/18 00:35
#include <string>#include <set>#include <algorithm>using namespace std;class Person{public:Person(const std::string& first_name, const std::string& last_name) :first_name_(first_name), last_name_(last_name){}std::string firstname() const { return first_name_;}std::string lastname() const {return last_name_;}private:std::string first_name_;std::string last_name_;};class PersonSortCriterion{public:bool operator()(const Person& lhs, const Person& rhs) {return lhs.lastname() < rhs.lastname() || (!(lhs.lastname() < rhs.lastname()) && lhs.firstname() < rhs.firstname());}};int _tmain(int argc, _TCHAR* argv[]){typedef std::set<Person, PersonSortCriterion> PersonSet;PersonSet ps;ps.insert(Person("ketty","Yang"));ps.insert(Person("ketty", "Xang"));ps.insert(Person("ketty", "Wang"));return 0;}
0 0
- 仿函数1-当排序规则
- STL之仿函数排序(1)
- C++标准库利用仿函数为map提供排序规则
- c++对结构体排序(仿函数)
- 01串排序。自定义比较仿函数
- STL map 排序(重载小于号和仿函数)
- 对字符串进行排序,学会使用仿函数
- 高级冒泡排序-->用模板仿函数再次实现
- 用仿函数实现保留索引的排序
- 排序规则
- 仿函数
- 仿函数
- 仿函数
- 仿函数
- 仿函数
- 仿函数
- 仿函数
- 仿函数
- “模”法无边-设计模式5
- Django Widgets(部件)
- 编程错误集锦(长期更新)
- Web前端--黑客技术揭秘(菜鸟知识)
- uva 10305
- 仿函数1-当排序规则
- 决策树的实现
- U盘中毒文件被隐藏的解决方法
- asm迁移到asm
- 【leetcode】Maximal Rectangle
- c语言scanf函数
- 设计模式之策略模式&简单工厂模式
- K近邻(KNN):分类算法
- 《C++标准程序库》读书笔记一