STL 之 Introducntion
来源:互联网 发布:淘宝1920海报显示不全 编辑:程序博客网 时间:2024/06/15 11:17
STL, is a C++ library of container classes, algorithms, and iterators; almost every component in the STL is a template.
Containers and algorithms
The STL includes the classes vector, list, deque, set, multiset, map, multimap, hash_set, hash_multiset, hash_map, and hash_multimap. algorithm is a global function, not a member function , it operates on a range of elements, rather than on a container. In this particular case the range happens to be the entire container . algorithm is decoupled from the STL container classes
Iterators
Pointers themselves are iterators, which is why it is possible to reverse the elements of a C array. Iterators are the mechanism that makes it possible to decouple algorithms from containers: algorithms are templates, and are parameterized by the type of iterator, so they are not restricted to a single type of container.
Concepts and Modeling
the arguments of algorithm's function implicitly defines a set of requirements on types, and that it may be instantiated with any type that satisfies those requirements. we call such a set of type requirements a concept ! We say that a type conforms to a concept, or that it is a model of a concept . programming in terms of concepts, rather than in terms of specific types, makes it possible to reuse software components and to combine components together.
Refinement
Refinement of concepts is very much like inheritance of C++ classes; the main reason we use a different word, instead of just calling it "inheritance", is to emphasize that refinement applies to concepts rather than to actual types.
Other parts of the STL
First, Assignable describes types that have assignment operators and copy constructors; almost all STL classes are models of Assignable, and almost all STL algorithms require their arguments to be models of Assignable .
Second, the STL includes some low-level mechanisms for allocating and deallocating memory. Allocators are very specialized, and you can safely ignore them for almost all purposes.
Finally, the STL includes a large collection of function objects, also known as functors.
- STL 之 Introducntion
- 【STL】STL之map
- 【STL】STL之set
- 【STL】STL之pair
- STL 5: STL之迭代器
- 【STL】STL容器之vector
- 【STL】STL容器之map
- 【STL】STL之string类
- STL 之 Container Concepts
- STL 之sort使用
- STL学习之(一)
- STL学习之(二)
- STL之学习笔记
- STL之xhash
- 学习STL之二
- STL算法之二
- STL之map
- STL之map
- C++编程思想笔记之二
- C++编程思想笔记之三
- C++编程思想笔记之五
- C++编程思想笔记之六
- C++编程思想笔记之四
- STL 之 Introducntion
- STL 之 Container Concepts
- 深度探索C++对象模型第一章 关于对象
- 深度探索C++对象模型第二章 构造函数语义学
- 深度探索C++对象模型第三章 Data 语意学
- 深度探索C++对象模型第四章 Data 语意学
- 深度探索C++对象模型第五章 构造、解构、拷贝语义学
- 深度探索C++对象模型第六章 执行其语义学
- 深度探索C++对象模型第七章 站在对象模型的尖端