- 博客(7)
- 收藏
- 关注
原创 c++中map与unordered_map的区别
头文件map: #include <map>unordered_map: #include <unordered_map>内部实现机理map: map内部实现了一个红黑树,该结构具有自动排序的功能,因此map内部的所有元素都是有序的,红黑树的每一个节点都代表着map的一个元素,因此,对于map进行的查找,删除,添加等一系列的操作都相当于是对红黑树进行这样的操作,故红黑树的效率决定了map的效率。红黑树效率:log nunordered_map: unord
2021-08-04 21:00:58
186
原创 c++智能指针
种类unique_ptrshared_ptrweak_ptrshared_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
82
原创 c++ STL allocator
1. 功能:所有容器身后:完成内存配置与释放,对象构造和析构的工作allocator参考: https://www.jianshu.com/p/a71bce469aa8
2021-08-01 23:38:04
78
原创 编译报错: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
530
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人