当前位置:网站首页>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;
}
边栏推荐
- Analysis of domestic data exchange platforms
- 【江科大自化协stm32F103c8t6】笔记之【入门32单片机及TIM定时中断初始化参数配置】
- [Punctuality Atom] Simple application of sys.c, sys.h bit-band operations
- 边境的悍匪—机器学习实战:第三章 分类
- How does MATLAB display nii file slice information in the image?
- 【Qingdao Station】High-level application of SWAT model and modeling of areas without data, uncertainty analysis and climate change, improvement of land use surface pollution impact model and case analy
- Through the bit operations to convert the characters are case sensitive
- 关于map对key自定义排序
- 边境的悍匪—Kaggle—泰坦尼克号生还预测详细教程
- 写在公众号之前——QT,ARM,DSP,单片机,电力电子与传动!
猜你喜欢

【江科大自化协stm32F103c8t6】笔记之【入门32单片机及TIM定时中断初始化参数配置】

点云统计滤波理解

原型模式(Prototype):Swift 实现

基于全球模式比较计划CMIP6与区域气候-化学耦合模式 WRF-Chem 的未来大气污染变化模拟

【速成MSP430f149】电赛期间学习MSP430f149笔记

基于OpenCV的双目重建

QT连载3:基于QT和STM32H750的LORA试验平台(2)

配置MMdetection环境并训练

Atmospheric particulate matter PMF source analysis

2021 soft exam intermediate pass
随机推荐
对于国内数据交换平台的分析
TCP为什么要三次握手,握手过程中丢包会怎么样?
clinit方法
二叉树(一):深度优先遍历与广度优先遍历
QT串口动态实时显示大量数据波形曲线(四)========“界面的美化与处理”
边境的悍匪—机器学习实战:第十章 Keras人工神经网络简介
通过位运算进行字符大小写转换
Knowledge distillation method of target detection
树莓派OpenCV+OpenCV-contrib
联影医疗一面
Through the bit operations to convert the characters are case sensitive
FPGA解析B码----连载2
卷积神经网络(CNN)之卷积操作、池化操作、激活函数
Pytorch(三):可视化工具(Tensorboard、Visdom)
DeepLearing4j深度学习之Yolo Tiny实现目标检测
Conda 安装 tensorflow gpu 1.13.1(验证可行)
C语言实战小项目(传统卡牌游戏)
无人机生态环境监测、图像处理与GIS数据分析
昆仑通态屏幕制作(连载1)---接触篇
CLUE Model Construction Method, Model Validation and Land Use Change Scenario Prediction