C++学习之标准库泛型算法_STL算法

来源:互联网 发布:nodejs于java跨域传值 编辑:程序博客网 时间:2024/06/04 19:40

参见http://www.cplusplus.com/reference/std/

标准库中的算法主要在algorithm、numeric两个头文件,注意有些是只能在C++11下使用,比如all_of,any_of。还有就是标准库算法的参数在C98下是需要程序员来确保正确的比如:

template <class OutputIterator, class Size, class T>OutputIterator fill_n (OutputIterator first, Size n, const T& val)

的参数n为非负,还有一些算法的迭代器范围的有效性也需要确保正确,否则会引起未定义的行为。

下面列出这两个头文件中的函数名和功能简介,具体算法模板的实现、复杂度、实例请参考上面的链接。

Functions in <algorithm>

Non-modifying sequence operations:

Modifying sequence operations:
Partitions:

Sorting:

Binary search (operating on partitioned/sorted ranges):

Merge (operating on sorted ranges):

Heap:

Min/max:

Other:

Functions in <numeric>

0 0
原创粉丝点击