- 博客(7)
- 收藏
- 关注
原创 c++中map与unordered_map的区别
头文件 map: #include <map> unordered_map: #include <unordered_map> 内部实现机理 map: map内部实现了一个红黑树,该结构具有自动排序的功能,因此map内部的所有元素都是有序的,红黑树的每一个节点都代表着map的一个元素,因此,对于map进行的查找,删除,添加等一系列的操作都相当于是对红黑树进行这样的操作,故红黑树的效率决定了map的效率。 红黑树效率:log n unordered_map: unord
2021-08-04 21:00:58
230
原创 c++智能指针
种类 unique_ptr shared_ptr weak_ptr shared_ptr实现 参考:https://www.jianshu.com/p/b6ac02d406a0 引用计数托管指针被引用的次数 简单实现: #include <iostream> using namespace std; template<class T> class shared_ptr{ private: T* m_ptr; //被封装的指针 unsigned int shared_c
2021-08-03 20:21:07
107
原创 c++ STL allocator
1. 功能:所有容器身后:完成内存配置与释放,对象构造和析构的工作 allocator 参考: https://www.jianshu.com/p/a71bce469aa8
2021-08-01 23:38:04
106
原创 编译报错:passing xxx as ‘this‘ argument of xxx discards qualifiers原因:const的函数不能调用非const函数stackoverfl
编译报错:passing xxx as 'this' argument of xxx discards qualifiers 原因:const的函数不能调用非const函数 stackoverflow:https://stackoverflow.com/questions/5973427/error-passing-xxx-as-this-argument-of-xxx-discards-qualifiers
2021-08-01 23:36:59
661
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人