C++ STL algorithm 列表

本文深入探讨了C++容器中的查找、排序、删除、替换、排列组合、算术、生成和异变、关系、集合和堆算法,提供详细说明和实际应用场景,帮助开发者高效利用容器特性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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,所以如果碰到哪个函数不好使,请不要怀疑这个函数,而是检查自己的用法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值