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. 头文件定义了一系列文件,处理容器,提供处理容器内容的不同操作。

  • Algorithm
    • Sorting 排序
    • Searching 搜索
    • Important STL Algorithms 重要的STL算法
    • Useful Array algorithms 有用的数组算法
    • Partition Operations 分区操作
  • Numeric
    • valarray class

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.实现了数据结构,可以以序列方式访问。
    • vector 向量
    • list 列表
    • deque 双端队列容器
    • arrays 数组
    • forward_list( Introduced in C++11)  列表
  • Container Adaptors(容器适配器) :  provide a different interface for sequential containers. 给序列容器提供不同的借口。
    • queue 队列
    • priority_queue 优先级队列
    • stack 栈
  • Associative Containers(关联式容器) :  implement sorted data structures that can be quickly searched (O(log n) complexity). 实现排序好的数据结构,可以快速搜索,时间复杂度O(logn)
    • set  集合
    • multiset 多重集合
    • map 映射
    • multimap 多重映射

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辅助相关函数在参数传递时特殊化。

  • 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. 迭代器用来处理一序列值。

  • Iterators 

Utility Library

Defined under

  • pair

References:

  • http://en.cppreference.com/w/cpp
  • http://cs.stmarys.ca/~porter/csc/ref/stl/headers.html

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:

  • Set in C++ Standard Template Library (STL)
  • Map in C++ Standard Template Library (STL)
  • List in C++ Standard Template Library (STL)
  • Pair in C++ Standard Template Library (STL)
  • Deque in C++ Standard Template Library (STL)
  • Sort in C++ Standard Template Library (STL)
  • Multimap in C++ Standard Template Library (STL)
  • Multiset in C++ Standard Template Library (STL)
  • Queue in Standard Template Library (STL)
  • Priority Queue in C++ Standard Template Library (STL)
  • Binary Search in C++ Standard Template Library (STL)
  • library in C++ STL
  • library in C++ STL
  • library in C++ STL
  • library in C++ STL

你可能感兴趣的:(c++)