08 2021 档案

摘要:宏定义常量和const变量比较: 1. 宏定义常量在预处理阶段进行替换,不进行类型检查; const变量在编译阶段进行类型检查; 2. 宏定义常量不存在于常量表中,系统不为其分配内存; const变量存在于常量表中,系统为其分配内存; 3. 大量使用宏,每次预编译都需进行替换,易导致编译时间过长; 阅读全文
posted @ 2021-08-30 21:53 封狼居胥! 阅读(624) 评论(0) 推荐(0)
摘要:#include <vector> #include <queue> #include <thread> #include <functional> #include <mutex> using namespace std; class ThreadPool { public: static con 阅读全文
posted @ 2021-08-29 23:16 封狼居胥! 阅读(118) 评论(0) 推荐(0)
摘要:#include <iostream> #include <queue> #include <thread> #include <mutex> #include <unistd.h> #include <condition_variable> using namespace std; #define 阅读全文
posted @ 2021-08-29 22:29 封狼居胥! 阅读(429) 评论(0) 推荐(0)
摘要:template <typename T> class shared_ptr { private: int* count; // 引用计数,不同shared_ptr指向同一引用计数 T* ptr; // 模板指针ptr,不同shared_ptr指向同一对象 public: // 构造函数 share 阅读全文
posted @ 2021-08-29 21:47 封狼居胥! 阅读(100) 评论(0) 推荐(0)
摘要:广度优先搜索的本质:在一幅图中,从一个起点,走到终点,求出最短路径。 伪代码: // 计算从起点 start 到终点 target 的最近距离 int BFS(Node start, Node target) { queue<Node> que; Set<Node> visited; //记录每个点 阅读全文
posted @ 2021-08-16 16:19 封狼居胥! 阅读(63) 评论(0) 推荐(0)