C++ STL algorithm 列表

简介:

1. 查找算法 (13)    为判断容器中是否包含某一个值提供

adjacent_find()

binary_search()

count()

count_if()

equal_range()

find()

find_end()

find_first_of()

find_if()

lower_bound()

upper_bound()

search()

search_n()

2. 排序(sorting)和通用(ordering)算法(14)

提供元素的排序策略。

其中stable算法保证相等元素的原来顺序不变。

inplace_merge()

merge()

nth_element()

partial_sort()

partial_sort_copy()

partition()

random_shuffle()

reverse()

reverse_copy()

rotate()

rotate_copy()

sort()

stable_sort()

stable_partition()

3. 删除和替换算法(15)

copy()

copy_backwards()

iter_swap()

remove()

remove_copy()

remove_if()

remove_copy_if()

replace()

replace_copy()

replace_if()

replace_copy_if()

swap()

swap_range()

unique()

unique_copy()

4. 排列组合算法(2)

提供计算给定集合按一定顺序的所有可能的排列组合。

next_permutation()

prev_permutation()

5. 算术算法(4)

accumulate()

partial_sum()

inner_product()

adjacent_difference()

6. 生成和异变算法(6)

fill()

fill_n()

for_each()

generate()

generate_n()

transform()

7. 关系算法(7)

equal()

includes()

lexicographical_compare()

max()

max_element()

min()

min_element()

mismatch()

8. 集合算法(4)

set_union()        合并2个集合

set_intersection()    取交集

set_difference()       取第一个集合减去第二个集合

set_symmetric_difference()    取只在一个集合中存在的元素集合

9. 堆算法(4)

make_heap()

pop_heap()

push_heap()

sort_heap()

 

注:有的算法函数需要容器中的值是排序的,如unique,所以如果碰到哪个函数不好使,请不要怀疑这个函数,而是检查自己的用法



本文转自einyboy博客园博客,原文链接:http://www.cnblogs.com/einyboy/archive/2012/09/08/2676300.html,如需转载请自行联系原作者。

目录
相关文章
|
1天前
|
存储 C++ 容器
C++:STL - set & map
C++:STL - set & map
10 4
|
1天前
|
算法 安全 程序员
【C++】STL学习之旅——初识STL,认识string类
现在我正式开始学习STL,这让我期待好久了,一想到不用手撕链表,手搓堆栈,心里非常爽
8 0
|
3天前
|
存储 Serverless C++
【C++入门到精通】哈希 (STL) _ unordered_map _ unordered_set [ C++入门 ]
【C++入门到精通】哈希 (STL) _ unordered_map _ unordered_set [ C++入门 ]
8 1
|
4天前
|
存储 设计模式 算法
【C++/STL】stack和queue(容器适配器、优先队列、双端队列)
【C++/STL】stack和queue(容器适配器、优先队列、双端队列)
10 1
|
4天前
|
存储 编译器 C++
【C++/STL】list(常见接口、模拟实现、反向迭代器、)
【C++/STL】list(常见接口、模拟实现、反向迭代器、)
5 0
|
4天前
|
算法 C++ 容器
【C++/STL】vector(常见接口、模拟实现、迭代器失效)
【C++/STL】vector(常见接口、模拟实现、迭代器失效)
9 0
|
10天前
|
存储 算法 C++
详解C++中的STL(标准模板库)容器
【4月更文挑战第30天】C++ STL容器包括序列容器(如`vector`、`list`、`deque`、`forward_list`、`array`和`string`)、关联容器(如`set`、`multiset`、`map`和`multimap`)和容器适配器(如`stack`、`queue`和`priority_queue`)。它们为动态数组、链表、栈、队列、集合和映射等数据结构提供了高效实现。选择合适的容器类型可优化性能,满足不同编程需求。
|
11天前
|
安全 程序员 编译器
【C++类和对象】初始化列表与隐式类型转换
【C++类和对象】初始化列表与隐式类型转换
|
16天前
|
存储 算法 程序员
C++从入门到精通:2.2.1标准库与STL容器算法深度解析
C++从入门到精通:2.2.1标准库与STL容器算法深度解析
|
17天前
|
编译器 C++ 容器
【C++11(一)】右值引用以及列表初始化
【C++11(一)】右值引用以及列表初始化