当前位置:网站首页>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 .
边栏推荐
- 用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案
- Wechat applet parameter transfer
- Jenkins 参数化构建中 各参数介绍与示例
- It won't last for 70 days. The k-largest number in the array
- 15.federation
- Cad2020 introductory learning (2021.4.13)
- C language force buckle question 61 of the rotating list. Double ended queue and construction of circular linked list
- Christmas tree web page and Christmas tree application
- The pit I walked through: the first ad Sketchpad
- 异常处理:pyemd或PyEMD找不到
猜你喜欢

14. Haproxy+kept load balancing and high availability

不会就坚持59天吧 替换单词
![Understand the Internet giant [the war between China and Taiwan] and the development thinking of China and Taiwan](/img/6c/f24407133663c0e19d6fa05c611341.png)
Understand the Internet giant [the war between China and Taiwan] and the development thinking of China and Taiwan

6. Pytest generates an allure Report

不会就坚持61天吧 最短的单词编码

顺序表和链表

The third ACM program design competition of Wuhan University of Engineering

用 ZEGO Avatar 做一个虚拟人|虚拟主播直播解决方案

不会就坚持65天吧 只出现一次的数字

Machine vision Series 1: Visual Studio 2019 dynamic link library DLL establishment
随机推荐
C language: enumerating knowledge points summary
C language force buckle question 61 of the rotating list. Double ended queue and construction of circular linked list
不会就坚持62天吧 单词之和
不会就坚持59天吧 替换单词
Installation and use of stm32cubemx (5.3.0)
不会就坚持64天吧 查找插入位置
settings.xml
Leetcode 686. KMP method of repeatedly superimposing strings (implemented in C language)
Pyscript cannot import package
Beginner: array & String
Exception handling: pyemd or pyemd not found
顺序表和链表
使用容器部署Jenkins
不会就坚持65天吧 只出现一次的数字
visio画网格
Post export data, return
Won't you just stick to 62 days? Sum of words
DASCTF2022.07赋能赛
Interview notes of a company
HC06 HC05 BT