随笔分类 -  C++

摘要:简单内存池的实现? 阅读全文
posted @ 2021-04-10 11:03 爱简单的Paul 阅读(74) 评论(0) 推荐(0)
摘要:对象池 比较类似内存池 设计实现思路: 构造函数中申请一批对象 析构函数中释放对象 提供获取和回收对象的接口 Get() 和 Recycle() 池子空了的时候支持扩容 参考链接: https://zhuanlan.zhihu.com/p/73066435 阅读全文
posted @ 2021-04-09 10:10 爱简单的Paul 阅读(214) 评论(0) 推荐(0)
摘要:模拟实现简单计数的智能指针的实现 阅读全文
posted @ 2021-04-07 14:42 爱简单的Paul 阅读(317) 评论(0) 推荐(0)
摘要:std::equal的使用https://www.inf.pucrs.br/~flash/lapro2ec/cppreference/w/cpp/algorithm/equal.html 阅读全文
posted @ 2020-12-16 23:03 爱简单的Paul 阅读(882) 评论(0) 推荐(0)
摘要:class Solution { public: void preorderTraversal(TreeNode* root) { //1.先逐个访问左路结点,并将其入栈 //2.再访问栈顶元素的右子树 stack<TreeNode*> helper; TreeNode* cur=root; //只 阅读全文
posted @ 2020-05-21 23:21 爱简单的Paul 阅读(368) 评论(0) 推荐(0)
摘要:在c++ 中,当我们定义一个类时,我们显式或隐式地定义了此类型的对象在拷贝、赋值和销毁时做什么? 一个类通过定义三种特殊成员成员函数来控制这些操作:拷贝构造函数、拷贝赋值函数、析构函数。 什么是三法则 C++三法则:如果需要析构函数,则一定需要拷贝构造函数和拷贝赋值操作符。 如何理解这句话,通常,若 阅读全文
posted @ 2020-05-07 23:55 爱简单的Paul 阅读(2765) 评论(0) 推荐(1)
摘要:常用的一种写法: static Single* get_instance() { static Single; return &Single; } 这种写法的好处就是不调用的时候不构造,用完程序结束自己销毁, 比较简洁. 详细参考:https://www.cnblogs.com/ccdev/arch 阅读全文
posted @ 2020-04-25 16:58 爱简单的Paul 阅读(170) 评论(0) 推荐(0)
摘要:博客参考 :http://www.cnhalo.net/2016/06/13/memory-optimize/ 1、系统的物理内存是有限的,而对内存的需求是变化的, 程序的动态性越强,内存管理就越重要,选择合适的内存管理算法会带来明显的性能提升。 阅读全文
posted @ 2019-09-23 23:39 爱简单的Paul 阅读(1144) 评论(0) 推荐(0)
摘要:1. supervisorctl start xxx 的用法 2. gdb attach pid 阅读全文
posted @ 2019-08-11 17:57 爱简单的Paul 阅读(250) 评论(0) 推荐(0)
摘要:1. Bazel是一个类似于Make的编译工具,是Google为其内部软件开发的特点量身定制的工具,如今Google使用它来构建内部大多数的软件。Google认为直接用Makefile构建软件速度太慢,结果不可靠,所以构建了一个新的工具叫做Bazel,Bazel的规则层级更高。 https://gi 阅读全文
posted @ 2019-06-05 13:45 爱简单的Paul 阅读(127) 评论(0) 推荐(0)
摘要:1. size_t 类型定义在cstddef头文件中,该文件是C标准库的头文件stddef.h的C++版。它是一个与机器相关的unsigned类型,其大小足以保证存储内存中对象的大小。 2. calloc 功 能: 在内存的动态存储区中分配n个长度为size的连续空间,函数返回一个指向分配起始地址的 阅读全文
posted @ 2019-05-31 19:02 爱简单的Paul 阅读(149) 评论(0) 推荐(0)
摘要:1. 工厂模式 2.typename 3. value_type 4.mutable__ 5. 虚基类 6.类的前向声明 7.dynamic_cast主要用于类层次间的上行转换和下行转换,还可以用于类之间的交叉转换。 8. git push origin与git push -u origin mas 阅读全文
posted @ 2019-02-25 16:41 爱简单的Paul 阅读(274) 评论(0) 推荐(0)
摘要:所谓静态链接是指把要调用的函数或者过程链接到可执行文件中,成为可执行文件的一部分。当多个程序都调用相同函数时,内存中就会存在这个函数的多个拷贝,这样就浪费了宝贵的内存资源。.so文件是共享库文件(动态链接)。动态链接所调用的函数代码并没有被拷贝到应用程序的可执行文件中去,而是仅仅在其中加入了所调用函 阅读全文
posted @ 2019-02-19 12:19 爱简单的Paul 阅读(2034) 评论(0) 推荐(0)
摘要:Debug:调试版本,包含调试信息,所以容量比Release大很多,并且不进行任何优化(优化会使调试复杂化,因为源代码和生成的指令间关系会更复杂),便于程序员调试。 Debug模式下生成两个文件,除了.exe或.dll文件外,还有一个.pdb文件,该文件记录了代码中断点等调试信息 Release:发 阅读全文
posted @ 2018-02-13 14:55 爱简单的Paul 阅读(320) 评论(0) 推荐(0)
摘要:Given two non-empty binary trees s and t, check whether tree t has exactly the same structure and node values with a subtree of s. A subtree of s is a 阅读全文
posted @ 2017-12-11 10:47 爱简单的Paul 阅读(191) 评论(0) 推荐(0)
摘要:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 ston 阅读全文
posted @ 2017-12-02 21:06 爱简单的Paul 阅读(130) 评论(0) 推荐(0)
摘要:Given an array and a value, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you 阅读全文
posted @ 2017-11-27 09:42 爱简单的Paul 阅读(149) 评论(0) 推荐(0)
摘要:1. tcp 连接的最大数量,tcp 用什么来标识 2. 多线程时如何避免互斥 3. protected 关键字 4. 动态库和静态库 5. 线程池 6.多继承时的虚表 网络编程需要加强 阅读全文
posted @ 2017-11-20 12:46 爱简单的Paul 阅读(655) 评论(0) 推荐(0)
摘要:1.懒汉模式。 2. 饿汉式: 饿汉式是线程安全的。 阅读全文
posted @ 2017-11-18 17:47 爱简单的Paul 阅读(602) 评论(0) 推荐(0)
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 递归实现: /* 阅读全文
posted @ 2017-11-17 23:40 爱简单的Paul 阅读(172) 评论(0) 推荐(0)