当前位置:网站首页>About custom comparison methods of classes and custom methods of sort functions
About custom comparison methods of classes and custom methods of sort functions
2022-06-11 05:04:00 【bolite】
The title of a ladder :21 Year of
L2-3 Inventory code base (25 branch )
The code borrows from the boss :
https://blog.csdn.net/weixin_45962741/article/details/116229100
Here, I want to summarize and record the custom comparison methods and sort Function custom comparison method
Class :
struct Node
{
vector<int>v;
int count;
bool operator<(const Node& vv)const {
if (vv.count == count) return v < vv.v;
else return count > vv.count;
}
};
Apply overload mechanism , change < perhaps >, Change his ranking basis
stay operator Redefine comparison rules in , It can be applied to map,set And so on
sort Function's custom comparison method
bool cmp(Node a, Node b) {
if (a.count == b.count) return a.v < b.v;
else return a.count > b.count;
}
Create a bool function , Inner structure comparison method , It can be applied to sort Function to sort classes by themselves .
sort(node.begin(), node.end(),cmp);
take cmp Attached to sort At the back of .
边栏推荐
- Temporary website English Writing
- 一大厂95后程序员对部门领导不满,删库跑路被判刑
- CONDA switching
- 华为设备配置MCE
- KD-Tree and LSH
- [NIPS2021]MLP-Mixer: An all-MLP Architecture for Vision
- New library goes online | cnopendata immovable cultural relic data
- 免费数据 | 新库上线 | CnOpenData全国文物商店及拍卖企业数据
- Cross modal retrieval | visual representation learning
- jvm调优六:GC日志分析和常量池详解
猜你喜欢

Huawei equipment is configured with cross domain virtual private network

NVIDIA SMI has failed because it could't communicate with the NVIDIA driver

Huawei equipment is configured to access the virtual private network through GRE

IOU series (IOU, giou, Diou, CIO)

Apply the intelligent OCR identification technology of Shenzhen Yanchang technology to break through the bottleneck of medical bill identification at one stroke. Efficient claim settlement is not a dr

华为设备配置本地虚拟专用网互访

高斯白噪声(white Gaussian noise,WGN)

Paper reproduction: pare

Feature engineering feature dimension reduction

Oh my Zsh correct installation posture
随机推荐
tensorflow1. X and tensorflow2 Conversion of X
【入门级基础】Node基础知识总结
Database introduction
华为设备配置BGP/MPLS IP 虚拟专用网
Iris dataset - Introduction to machine learning
Share | guide language image pre training to achieve unified visual language understanding and generation
Conversion relationship between coordinate systems (ECEF, LLA, ENU)
Take stock of the AI black technologies in the Beijing Winter Olympic Games, and Shenzhen Yancheng Technology
Zed2 camera calibration -- binocular, IMU, joint calibration
[entry level basics] node basic knowledge summary
Lr-link Lianrui fully understands the server network card
工具类ObjectUtil常用的方法
Paper reproduction: pare
Share 𞓜 jointly pre training transformers on unpaired images and text
力扣(LeetCode)161. 相隔为 1 的编辑距离(2022.06.10)
Network security construction in 5g Era
[Transformer]MViTv1:Multiscale Vision Transformers
董明珠称“格力手机做得不比苹果差”哪里来的底气?
Possible errors during alphapose installation test
JVM tuning V: JVM tuning tools and tuning practice