摘要: #include <bits/stdc++.h> using namespace std; // 定义line结构,一条边的2个端点(x,y) 和权重 quan struct line{ int x; int y; int quan; }; // 自定义比较器,按quan 升序排列 bool cmp 阅读全文
posted @ 2022-04-17 23:34 子于舟 阅读(48) 评论(0) 推荐(0)
摘要: #include<stdc++.h> #include <iostream> using namespace std; class ufset{ public: static const int N = 100010; int p[N]; // p[i]看做i的指针,该指针指向其父节点。 int c 阅读全文
posted @ 2022-03-27 10:01 子于舟 阅读(127) 评论(0) 推荐(0)
摘要: class Observer{ public: Observer(int id):m_id(id){}; void obPirnt(){ cout << "obj " << m_id << " find change!" << endl; } private: int m_id; }; class 阅读全文
posted @ 2022-02-08 20:06 子于舟 阅读(33) 评论(0) 推荐(0)
摘要: // 手写小根堆 template<typename T> class lyhMinHeap{ public: lyhMinHeap(int size = 10){ maxSize = size; heap = new T[maxSize]; curSize = 0; } bool Insert(c 阅读全文
posted @ 2022-02-02 11:17 子于舟 阅读(379) 评论(0) 推荐(0)
摘要: template<typename T> class Msp{ public: Msp(T* ptr = nullptr):m_ptr(ptr){ if(m_ptr == nullptr) m_count = new int(0); else m_count = new int(1); } ~Msp 阅读全文
posted @ 2022-01-28 21:39 子于舟 阅读(34) 评论(0) 推荐(0)
摘要: 待加入 阅读全文
posted @ 2022-01-18 17:25 子于舟 阅读(16) 评论(0) 推荐(0)
摘要: #ifndef THREADPOOL_H #define THREADPOOL_H #include <pthread.h> // 导入线程池头文件 #include <list> // 请求队列 #include "locker.h" // 自己写的互斥锁 #include <exception> 阅读全文
posted @ 2022-01-14 09:14 子于舟 阅读(300) 评论(1) 推荐(0)
摘要: 原理:当cin>>从缓冲区中读取数据时,若缓冲区中第一个字符是空格、tab或换行这些分隔符时,cin>>会将其忽略并清除,继续读取下一个字符,若缓冲区为空,则继续等待。但是如果读取成功,字符后面的分隔符是残留在缓冲区的,cin>>不做处理。 若:不想略过空白字符,那就使用noskipws流控制。比如 阅读全文
posted @ 2022-01-06 13:52 子于舟 阅读(95) 评论(0) 推荐(0)
摘要: 什么是内联函数(关键词 inline)? 编译器将(内联)函数的函数体代码插入并取代每一处调用该函数的地方,这样的函数成为内联函数。 // 内联函数范例 inline int Max(int x, int y){ return (x > y)? x : y; } 什么时候使用内联函数? 因为函数进出 阅读全文
posted @ 2022-01-06 10:01 子于舟 阅读(50) 评论(0) 推荐(0)
摘要: 使用C++做算法题时,与priority_queue相关的常用操作: 头文件 #include < queue> 创建 queue q; 是否为空 q.empty(); 入队 q.push(x); 出队 q.pop(); 队头 q.front(); 队尾 q.back(); 大小 q.size(); 阅读全文
posted @ 2021-12-29 13:02 子于舟 阅读(33) 评论(0) 推荐(0)