C++ 标准模板库

来自cppreference.com
< cpp
跳转到: 导航, 搜索


C++ STL (Standard Template Library,标准模板库)是一个模板与算法的类集合。它可以使程序员很方便地实现一些标准的数据结构,比如队列、链表以及栈。

目录

[编辑] STL Containers (STL 容器)

The C++ STL provides two kinds of containers:

C++ STL 提供两类容器:


In addition, the C++ standard library provides several non-STL containers.
They can be considered containers, but don't meet all the requirements of STL containers.

另外, C++ 标准库还提供一些 非-STL 容器。
可以认为它们是容器,但是他们并不满足 STL 容器的所有要求。



The idea behind the C++ STL is that the hard part of using complex data structures has already been completed. If a programmer would like to use a stack of integers, all one has to do is use this code:

C++ STL 的初衷是,使用复杂数据的困难部分已经解决了。如果程序员想使用整数 stack,唯一要做的就是使用下面的代码:

  stack<int> myStack;

With minimal effort, one can now cn/stl/stack/push and cn/stl/stack/pop integers onto this stack. Through the magic of C++ Templates, one could specify any data type, not just integers. The STL Stack class will provide generic functionality of a stack, regardless of the data in the stack.

只要做一点点事,他就能 push 和 pop 整数到这个 stack 中。通过使用强大的 C++ 模板,他还能使用任何数据类型,而不仅仅是整数。STL Stack 提供一个 stack 通用的方法,不管 stack 里是什么样的数据。

[编辑] Algorithms (算法)

In addition, the STL also provides a bunch of useful algorithms -- such as cn/stl/algorithm/binary_search, cn/stl/algorithm/sort, and cn/stl/algorithm/for_each -- that can be used on a variety of containers or data structures.

另外, STL 还提供大量有用的 算法 -- 例如 cn/stl/algorithm/binary_search, cn/stl/algorithm/sort,和 cn/stl/algorithm/for_each -- 大部分的容器或数据结构都可以使用它们。

[编辑] Iterators (迭代器)

cn/stl/iterators provide a generic way of iterating over the STL containers or other data structures.

cn/stl/iterators 提供了一个通用的方法来迭代 STL 容器或其他数据结构。


[编辑] Function Objects (函数对象)

The <functional> header file defines function objects and function adapters.

<functional> 头文件 定义了函数对象和函数适配器。

[编辑] Memory (内存)

The <memory> header file provides simple memory management structures like cn/stl/memory/auto_ptr.

<memory> 头文件 提供了像 cn/stl/memory/auto_ptr 之类的简单内存管理结构。

[编辑] Utility (其他)

There are several generic utility methods like cn/stl/utility/make_pair in the <utility> header file.

<utility> 头文件 中定义了其他一些常用的方法,例如: cn/stl/utility/make_pair

个人工具
名字空间
操作
导航
工具箱
其他语言