当前位置:网站首页>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 .
边栏推荐
- Labelme cannot open the picture
- oracle 更新和删除数据
- The daily life of programmers
- Locally call tensorboard and Jupiter notebook on the server (using mobaxterm)
- 11. Backup switch
- What is the difference between field, variable and property
- C language: typedef knowledge points summary
- C language: talking about various complex statements
- Hengxing Ketong invites you to the 24th China expressway informatization conference and technical product exhibition in Hunan
- Two forms of softmax cross entropy + numpy implementation
猜你喜欢

9.延迟队列

Not 67 days, square root

Jenkins 参数化构建中 各参数介绍与示例

Webrtc realizes simple audio and video call function

Idea small settings

Record the Niua packaging deployment project

The principle of inverse Fourier transform (IFFT) in signal processing

Make a virtual human with zego avatar | virtual anchor live broadcast solution

Can you really write restful API?

Record of problems encountered in ROS learning
随机推荐
读懂 互联网巨头 【中台之战】 以及 中台 发展思维
Shielding ODBC load balancing mode in gbase 8A special scenarios?
Dasctf2022.07 empowerment competition
不会就坚持68天吧 狒狒吃香蕉
es6和commonjs对导入导出的值修改是否影响原模块
Pyscript cannot import package
VScode 一键编译和调试
Not 67 days, square root
Understand the Internet giant [the war between China and Taiwan] and the development thinking of China and Taiwan
On the use of pyscript (realizing office preview)
Two forms of softmax cross entropy + numpy implementation
DASCTF2022.07赋能赛
Pix2.4.8 from start to installation (2021.4.4)
9.延迟队列
Sequence list and linked list
恒星科通邀您“湘”约第24届中国高速公路信息化大会暨技术产品展示会
Deploy Jenkins using containers
Idea small settings
C language: typedef knowledge points summary
C语言力扣第61题之旋转链表。双端队列与构造循环链表