The C++ Standard Template Library (STL) -- C++的标准模板库

The Standard Template Library (STL) is a set of C++ template classes to provide common programming data structures and functions such as lists, stacks, arrays, etc. It is a library of container classes, algorithms and iterators. It is a generalized library and so, its components are parameterized. A working knowledge of template classes is a prerequisite  for working with STL. STL是一系列C++模板类,提供常见的编程数据结构和函数,比如lists,stacks,arrays等,是一个容器类,算法,迭代器的库。

STL has four components STL包含4部分

  • Algorithms 算法
  • Containers 容器
  • Functions 函数
  • Iterators 迭代器

Algorithms 算法

The header algorithm defines a collection of functions especially designed to be used on ranges of elements.They act on containers and provide means for various operations  for the contents of the containers. 头文件定义了一系列文件,处理容器,提供处理容器内容的不同操作。

Containers 容器

Containers or container classes store objects and data. There are in total seven standard “first-class” container classes  and three container adaptor classes and only seven header files that provide access to these containers or container adaptors.容器或容器类存储数据,共有7个标准的容器类,3个容器adapter类和7个头文件,他们提供了访问容器的方法。

  • Sequence Containers(序列容器):  implement data structures which can be accessed in a sequential manner.实现了数据结构,可以以序列方式访问。
  • Container Adaptors(容器适配器) :  provide a different interface for sequential containers. 给序列容器提供不同的借口。
  • Associative Containers(关联式容器) :  implement sorted data structures that can be quickly searched (O(log n) complexity). 实现排序好的数据结构,可以快速搜索,时间复杂度O(logn)

Functions函数

The STL includes classes that overload the function call operator. Instances of such classes are called function objects or functors. Functors allow the working of the associated function to be customized with the help of parameters to be passed. STL包含了重载函数调用运算符的类,叫做类的函数对象或函数的实例,Functors辅助相关函数在参数传递时特殊化。

Iterators

As the name suggests, iterators are used for working upon a sequence of values. They are the major feature that allow generality in STL. 迭代器用来处理一序列值。

Utility Library

扫描二维码关注公众号,回复: 4985363 查看本文章

Defined under <utility header>

References:

Recent articles on STL!

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

Recommended Posts:

猜你喜欢

转载自blog.csdn.net/qq_27009517/article/details/86520874