当前位置:网站首页>STL source code analysis (Hou Jie) notes - STL overview
STL source code analysis (Hou Jie) notes - STL overview
2022-07-29 04:29:00 【Lishizhen land】
1、STL The difference with object-oriented
Basically no use of various virtual function , Inheritance, etc , Mainly used templates Made out of
2、STL Six parts
distributor (allocator)、 Containers 、 iterator 、 functor 、 Algorithm 、 Adapter
3、C++ Standard library and STL The relationship between
C++ Standard library >STL,STL It contains six parts ,C++ The standard library also contains some other things
4、STL The relationship between the six components
Containers : Containers can let us not pay attention to memory management , Add elements directly into it , Therefore, the container needs the support of the distributor .
distributor : Implement memory management of containers .
Algorithm : Reflect the relationship with OOP The difference between , And the data section ( Containers ) Separate , The object-oriented idea will put data and functions into classes to contain .
iterator : A generalized pointer , Implement operations such as finding containers .
functor : The functionality , Realize the addition, addition, subtraction, etc. of objects , Conceptual
Adapter : Some parts can be converted , Include container 、 functor 、 Algorithm adapter
Code case :
The above figure contains six parts , We can explore allocator How to use .
5、 The iterator is closed before and opened after
For all containers , Its iterator begin() and end() Meaning is closed before opening , namely begin() Point to 0 Elements ,end Point to the next position of the last element .
Container<T> c;
Container<T>::iterator iter = c.begin();
for (; iter != c.end(); ++iter) // For condition judgment !=,iter++ Until end, That is, traverse all elements
Above picture ,c.end() The location pointed to is the next location of the memory space of the last element in the container , Non container space .*(c.begin()) To dereference ,*(c.end()) Invalid , because c.end() The memory of the location does not belong to the container itself .
边栏推荐
- Pytorch fixed random seed & recurrence model
- Mpc5744p introduction and opensda firmware update
- settings.xml
- Definition and implementation of stack and queue (detailed)
- Cad2020 introductory learning (2021.4.13)
- kotlin的List,Map,Set等集合类不指定类型
- i++与++i详解
- 顺序表和链表
- mpc5744p简介与OpenSDA固件更新
- MySQL - clustered index and secondary index
猜你喜欢
12.优先级队列和惰性队列
Webrtc realizes simple audio and video call function
Record the Niua packaging deployment project
Post export data, return
Pytoch distributed training
不会就坚持58天吧 实现前缀树
MySQL - deep parsing of MySQL index data structure
C语言力扣第61题之旋转链表。双端队列与构造循环链表
Use of construction methods
6. Pytest generates an allure Report
随机推荐
Mongo Shell交互式命令窗口
Multi card training in pytorch
Shell string segmentation
Two forms of softmax cross entropy + numpy implementation
Laya中的A星寻路
Don't stick to it for 68 days. Baboons eat bananas
leetcode 686.重复叠加字符串 KMP方法(C语言实现)
No, just stick to it for 59 days
10. Fallback message
Whether the modification of import and export values by ES6 and commonjs affects the original module
9. Delay queue
On quotation
不会就坚持59天吧 替换单词
Model tuning, training model trick
Record the Niua packaging deployment project
Class starts! See how smardaten decomposes complex business scenarios
[material delivery UAV] record (ROS + Px4 + yolov5 + esp8266 + steering gear)
12. Priority queue and inert queue
Vscode one click compilation and debugging
C语言:结构体简单语法总结