当前位置:网站首页>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;
}
边栏推荐
猜你喜欢

DeepLearing4j's deep learning Yolo Tiny realizes target detection

Xcode 绑定按钮点击事件

边境的悍匪—机器学习实战:第九章 无监督学习任务

十一、Kotlin进阶学习:1、集合;2、List操作;3、可变集合——MutableList;4、Set;5、Map;6、MutableMap;

Generalized Focal Loss 论文阅读笔记

无人机生态环境监测、图像处理与GIS数据分析

原型模式(Prototype):Swift 实现

i++与 ++i 的区别

边境的悍匪—Kaggle—泰坦尼克号生还预测详细教程

昆仑通态屏幕制作(连载5)---基础篇(串口接收,文本与灯显示)
随机推荐
思谋面试准备
八、Kotlin基础学习:1、数据类;2、单例;3、伴生对象;4、密封类;
与所有 ARM 工具、软件兼容?韦斯佰瑞这款MCU内核值得关注!
边境的悍匪—机器学习实战:第七章 集成学习和随机森林
User password encryption using Bcrypt instead of MD5, SHA1 and SHA256
单例模式:Swift 实现
基于OpenCV的相机标定流程
十一、Kotlin进阶学习:1、集合;2、List操作;3、可变集合——MutableList;4、Set;5、Map;6、MutableMap;
通过位运算进行字符大小写转换
Pytorch(二):数据读取机制(DataLoader、DataSet)与图像预处理模块(transforms)
Xcode 绑定按钮点击事件
ssh 脚本 空格字符转换
Target detection, object classification and semantic segmentation of UAV remote sensing images based on PyTorch deep learning
逻辑右移和算术右移区别
基于遥感解译与GIS技术环境影响评价图件制作(最新导则)
C语言实战小项目(传统卡牌游戏)
边境的悍匪—机器学习实战:第十五章 使用CNN和RNN处理序列
边境的悍匪—机器学习实战:第一章 机器学习的基础知识
联影医疗一面
边境的悍匪—机器学习实战:第八章 降维