STL INTRODUCNTION

zhaozj2021-02-16  57

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 constainer. 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

转载请注明原文地址:https://www.9cbs.com/read-24326.html

New Post(0)