STL 之 Introducntion

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.


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值