面向招聘要求和面经学习
基础语法 + 面经
利用宿舍时间10:00-11:00 C++ Primer
牛客网面经、习题
操作系统(重点)
网课:CMU15-413
书籍:CSAPP + 现代操作系统
项目相关:labs
牛客网习题
计网
网课:王道
小林coding
数据库
网课:CMU15-445
书籍:MySQL必知必会(REDIS?)
小林coding
数据结构
蓝桥杯真题库 + 代码随想录LeetCode + CODETOP
每日两题
嵌入式
Linux原子哥
webserver项目
C++ set自定义排序问题
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 
 | class node {public:
 int x;
 int y;
 int stime;
 int fintime;
 
 node(int xx, int yy, int st ,int ot) : x(xx), y(yy), stime(st), fintime(st + ot) {}
 
 bool operator < (node n) const
 {
 if (n.fintime != fintime)
 return fintime < n.fintime;
 else if (x != n.x)
 return x < n.x;
 else
 return y < n.y;
 }
 
 bool operator < (const node* n) const
 {
 if (n->fintime != fintime)
 return fintime < n->fintime;
 else if (x != n->x)
 return x < n->x;
 else
 return y < n->y;
 }
 };
 
 | 
利用 < 运算符重载,如果set<node*> nodes,此时排序会出现混乱
而定义set<node> nodes则不会,并且使用仿函数也正常
| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 
 | class comp{public:
 bool operator()( const node& l, const node& r) const
 {
 if (l.fintime != r.fintime)
 return l.fintime < r.fintime;
 else if (l.x != r.x)
 return l.x < r.x;
 else
 return l.y < r.y;
 }
 };
 
 | 
set<node, comp> nodes或set<node*, comp> nodes