当前位置:网站首页>About map custom sorting of keys
About map custom sorting of keys
2022-07-30 07:13:00 【Yin Pinghua】
The map sorts the keys from small to large by default
You can also customize the sorting
#include
#include
// Define your own std::map comparator
template
struct PLess
{
// functor for operator<
bool operator()(const _Ty& pLeft, const _Ty& pRight) const
{
// apply operator< to operands
// return pLeft > pRight; // where this comparator differs from the default comparator
// }
};
int main()
{
// If Key is a pointer, in order to sort correctly, you need to define your own comparator object
std::map
datas[1] = 3;
datas[2] = 2;
datas[3] = 1;
return 0;
}
边栏推荐
- Basic application of XMLBean
- 边境的悍匪—机器学习实战:第十二章 使用TensorFlow自定义模型和训练
- 边境的悍匪—机器学习实战:第十五章 使用CNN和RNN处理序列
- Massive remote sensing data processing and application of GEE cloud computing technology [basic, advanced]
- 边境的悍匪—机器学习实战:第十一章 训练深度神经网络
- Generalized Focal Loss paper reading notes
- 用户密码加密编码使用 Bcrypt 代替 MD5,SHA1和SHA256
- 电子工程师怎么才能规范设计标准、提高设计效率?
- 边境的悍匪—机器学习实战:第十三章 使用TensorFlow加载和预处理数据
- 求职准备知识点
猜你喜欢
Configure MMdetection environment and train
influxDB运维记录
TCP建立连接的过程
UAV ecological environment monitoring, image processing and GIS data analysis
Simulation of Future Air Pollution Changes Based on Global Model Comparison Program CMIP6 and Regional Climate-Chemistry Coupling Model WRF-Chem
高交会重要活动之一|2020中国硬件创新大赛全国总决赛
二叉树(一):深度优先遍历与广度优先遍历
QT连载3:基于QT和STM32H750的LORA试验平台(2)
"R Language + Remote Sensing" Comprehensive Evaluation Method of Water Environment
Pytorch(三):可视化工具(Tensorboard、Visdom)
随机推荐
遥感、GIS和GPS技术在水文、气象、灾害、生态、环境及卫生等应用
无人机生态环境监测、图像处理与GIS数据分析
influxDB运维记录
CLUE模型构建方法、模型验证及土地利用变化情景预测
十、Kotlin基础学习:1、延迟加载;2、异常处理;3、使用 throw 主动抛出异常;4、自定义异常;
边境的悍匪—机器学习实战:第七章 集成学习和随机森林
Application of remote sensing, GIS and GPS technology in hydrology, meteorology, disaster, ecology, environment and health
QT每周技巧(2)~~~~~~~~~界面按钮
ssh 脚本 空格字符转换
探究make_shared效率
基于MATLAB 2021b的机器学习、深度学习
高效插入map数据
经典排序之插入排序
QT每周技巧(3)~~~~~~~~~串口添加
R language application in the field of ecological environment
2021年软考中级过关
建造者模式(Swift 实现)
Xcode 绑定按钮点击事件
十三、Kotlin进阶学习:内联函数let、also、with、run、apply的用法。
昆仑通态屏幕制作(连载4)---基础篇(图形设定与显示,按钮灯)