摘要: 1 int ngx_cdecl 2 main(int argc, char *const *argv) 3 { 4 ngx_buf_t *b; 5 ngx_log_t *log; 6 ngx_uint_t i; 7 ngx_cycle_t *cycle, init_cycle; 8 ngx_conf 阅读全文
posted @ 2021-03-08 11:39 wa小怪兽 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 面试的时候居然写炸了。补一下 1 #include <iostream> 2 3 using namespace std; 4 5 struct ListNode { 6 int val; 7 ListNode *next; 8 ListNode() : val(0), next(nullptr) 阅读全文
posted @ 2021-03-07 18:03 wa小怪兽 阅读(50) 评论(0) 推荐(0) 编辑
摘要: 安装qt相关库: sudo apt install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qt5-default 安装qt-creater: sudo apt install qtcreator 添加环 阅读全文
posted @ 2021-02-20 17:42 wa小怪兽 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 多叉树存储的方式: 采用链表的方式维护子节点,每个结点的child指针指向子节点链表的首节点。通过next指针即可遍历子节点链表。 采用迭代器模式的设计思路,封装了多叉树dfs遍历接口:iterator_node以及bfs遍历接口:iterator_leval_node。 iterator_node 阅读全文
posted @ 2021-02-04 19:31 wa小怪兽 阅读(282) 评论(0) 推荐(0) 编辑
摘要: 面试问了这道题,居然没想出最优解,记录下。 #include <iostream> #include <cstring> using namespace std; void str_turn (char *str, int len) { for (int i = 0; i < len/2; i++) 阅读全文
posted @ 2021-01-20 11:14 wa小怪兽 阅读(135) 评论(0) 推荐(0) 编辑
摘要: Linux源码中include/linux/list.h封装了双向链表的数据结构。 网上实现双向链表的方式大抵相同,都是定义一个struct Node表示链表的节点,Node结构体包含指向节点数据的指针,和指向节点的next和pre指针: 1 struct Node { 2 void *data; 阅读全文
posted @ 2021-01-11 23:20 wa小怪兽 阅读(695) 评论(0) 推荐(0) 编辑
摘要: C++通过以下两个运算符进行运行时类型识别: 1. typeid 查询类型的信息 在使用typeid前需要包含typeinfo头文件。 #include <typeinfo> 当typeid查询多态类型表达式时,将会有虚表查找的开销,查询其他表达式在编译前即完成。 可以通过typeinfo::nam 阅读全文
posted @ 2020-11-02 19:35 wa小怪兽 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 使用perf工具以及flamegraph将调试的程序运行栈以及在每个函数中停留的时间以火焰图的形式展现出来,以可视化的方式进行调试。 阅读全文
posted @ 2020-10-26 11:59 wa小怪兽 阅读(781) 评论(0) 推荐(0) 编辑
摘要: 在一些系统调用中需要指定时间是用CLOCK_MONOTONIC还是CLOCK_REALTIME。 CLOCK_MONOTONIC是monotonic time,而CLOCK_REALTIME是wall time。 monotonic time字面意思是单调时间,实际上它指的是系统启动以后流逝的时间, 阅读全文
posted @ 2020-10-15 14:51 wa小怪兽 阅读(496) 评论(0) 推荐(0) 编辑
摘要: 1 ngx_int_t 2 ngx_os_init(ngx_log_t *log) 3 { 4 ngx_time_t *tp; 5 ngx_uint_t n; 6 #if (NGX_HAVE_LEVEL1_DCACHE_LINESIZE) 7 long size; 8 #endif 9 10 #if 阅读全文
posted @ 2020-09-27 21:18 wa小怪兽 阅读(255) 评论(0) 推荐(0) 编辑