文章目录
vector底层实现原理
vector内存增长机制
代码示例
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> vec1;
for (int i = 1; i <= 10; i ++) {
vec1.push_back(i);
cout << i << "\t" << vec1.capacity() << endl;
}
return 0;
}
1 1
2 2
3 4
4 4
5 8
6 8
7 8
8 8
9 16
10 16
#include <vector>
#include <iostream>
using namespace std;
int main() {
vector<int> vec1(10);
cout << 10 << "\t" << vec1.capacity() << endl;
for (int i = 11; i <= 21; i ++) {
vec1.push_back(i);
cout << i << "\t" << vec1.capacity() << endl;
}
return 0;
}
10 10
11 20
12 20
13 20
14 20
15 20
16 20
17 20
18 20
19 20
20 20
21 40
vector中reserve和resize的区别
vector中的元素为什么不能是引用
list底层实现原理
deque底层实现原理
什么时候使用vector、list以及deque
priority_queue的底层实现原理
multiset的底层实现原理
typedef struct TreeNode {
struct TreeNode *parent;
struct TreeNode *left;
struct TreeNode *right;
int key;
int data;
} TreeNode;
void inOrder(TreeNode *node) {
if (node != null) {
inOrder(node->left);
printf("k:%d v:%d", node->key, node->data);
inOrder(node->right);
}
}
unordered_map的底层实现
迭代器底层实现原理?有哪些种类?
迭代器失效?连续和非连续存储容器的失效?
STL容器线程安全性
参考
推荐一个零声学院免费公开课程,个人觉得老师讲得不错,分享给大家:[Linux,Nginx,ZeroMQ,MySQL,Redis,fastdfs,MongoDB,ZK,流媒体,CDN,P2P,K8S,Docker,TCP/IP,协程,DPDK等技术内容,点击立即学习:https://course.0voice.com/v1/course/intro?courseId=5&agentId=0