标准库算法

标准库算法的同一描述:
beg和end是表示元素范围的迭代器,所有算法都对一个由beg和end表示的序列进行操作。
beg2是表示第二个输入序列开始位置的迭代器。如果没有end2,则假定beg2表示的序列与beg和end表示的序列一样大。beg和beg2类型不必匹配。
dest表示目标序列的迭代器。
unaryPred和binaryPred是一元和二元谓词。分别表示接受一个和两个参数,都是来自输入序列的元素。
comp是二元谓词。
unaryOp和binaryOp是可调用对象,分别使用来自输入序列的一个和两个实参来调用。

查找对象的算法

//简单查找
find(beg,end,val)
find_if(beg,end,unaryPred)
find_if_not(beg,end,unaryPred)
count(beg,end,val)
count_if(beg,end,unaryPred)

//查找重复值
adjacent_find(beg,end)
adjacent_find(beg,end,binaryPred)
search_n(beg,end,count,val)
search_n(beg,end,count,val,binaryPred)

//查找子序列
search(beg1,end1,beg2,end2)
search(beg1,end1,beg2,end2,binaryPred)
find_first_of(beg1,end1,beg2,end2)
find_first_of(beg1,end1,beg2,end2,binaryPred)
find_end(beg1,end1,beg2,end2)
find_end(beg1,end1,beg2,end2,binaryPred)

其他只读算法

for_each(beg,end,unaryOp)
mismatch(beg1,end1,beg2)
mismatch(beg1,end1,beg2,binaryPred)
equal(beg1,end1,beg2)
equal(beg1,end1,beg2,binaryPred)

二分搜索算法

lower_bound(beg,end,val)
lower_bound(beg,end,val,comp)
upper_bound(beg,end,val)
upper_bound(beg,end,val,comp)
equal_range(beg,end,val)
equal_range(beg,end,val,comp)
binary_search(beg,end,val)
binary_search(beg,end,val,comp)

写容器元素的算法

fill(beg,end,val)
fill_n(dest,cnt,val)
generate(beg,end,Gen)
generate_n(dest,cnt,Gen)

copy(beg,end,dest)
copy_if(beg,end,dest,unaryPred)
copy_n(beg,n,dest)

move(beg,end,dest)

transform(beg,end,dest,unaryOp)
transform(beg,end,beg2,dest,binaryOp)

replace_copy(beg,end,dest,old_val,new_val)
replace_copy_if(beg,end,dest,unaryPred,new_val)

merge(beg1,end1,beg2,end2,dest)
merge(beg1,end1,beg2,end2,dest,comp)

iter_swap(iter1,iter2)
swap_ranges(beg1,end1,beg2)

replace(beg,end,old_val,new_val)
replace_if(beg,end,unaryPred,new_val)

copy_backward(beg,end,dest)
move_backward(beg,end,dest)

inplace_merge(beg,mid,end)
inplace_merge(beg,mid,end,comp)

划分与排序算法

//划分
is_partition(beg,end,unaryPred)
partition_copy(beg,end,dest1,dest2,unaryPred)
partition_point(beg,end,unaryPred)
stable_partition(beg,end,unaryPred)
partition(beg,end,unaryPred)

//排序
sort(beg,end)
stable_sort(beg,end)
sort(beg,end,comp)
stable_sort(beg,end,comp)

is_sorted(beg,end)
is_sorted(beg,end,comp)
is_sorted_until(beg,end)
is_sorted_until(beg,end,comp)

partial_sort(beg,mid,end)
partial_sort(beg,mid,end,comp)

partial_sort_copy(beg,end,destBeg,destEnd)
partial_sort_copy(beg,end,destBeg,destEnd,comp)

nth_element(beg,nth,end)
nth_element(beg,nth,end,comp)

通用重排算法

remove,unique,reverse,rotate,random_shuffle

remove(beg,end,val)
remove_if(beg,end,unaryPred)
remove_copy(beg,end,dest,val)
remove_copy_if(beg,end,dest,unaryPred)

unique(beg,end)
unique(beg,end,binaryPred)
unique_copy(beg,end,dest)
unique_copy(beg,end,dest,binaryPred)

rotate(beg,mid,end)
rotate_copy(beg,mid,end,dest)

reverse(beg,end)
reverse_copy(beg,end)

random_shuffle(beg,end)
random_shuffle(beg,end,rand)
shuffle(beg,end,Uniform_rand)

排列算法

is_permutation(beg1,end1,beg2)
is_permutation(beg1,end1,beg2,binaryPred)
next_permutation(beg,end)
next_permutation(beg,end,comp)
prev_permutation(beg,end)
prev_permutation(beg,end,comp)

有序序列的集合算法

includes(beg,end,beg2,end2)
includes(beg,end,beg2,end2,comp)
set_union(beg,end,beg2,end2,dest)
set_union(beg,end,beg2,end2,dest,comp)
set_intersection(beg,end,beg2,end2,dest)
set_intersection(beg,end,beg2,end2,dest,comp)
set_difference(beg,end,beg2,end2,dest)
set_difference(beg,end,beg2,end2,dest,copm)
set_symmetric_difference(beg,end,beg2,end2,dest)
set_symmetric_difference(beg,end,beg2,end2,dest,comp)

最大最小值

min(val1,val2)
min(val1,val2,comp)
min(init_list)
min(init_list,comp)
//min可以替换成max

minmax(val1,val2)
minmax(val1,val2,comp)
minmax(init_list)
minmax(init_list,comp)

min_element(beg,end)
min_element(beg,end,comp)
minmax_element(beg,end)
minmax_element(beg,end,comp)

数值算法

//求和
accumulate(beg,end,init)
accumulate(beg,end,int,binaryOp)

//内积
inner_product(beg1,end1,beg2,init)
inner_product(beg1,end1,beg2,init,binOp1,binOp2)
partial_sum(beg,end,dest)
partial_sum(beg,end,dest,binaryOp)
adjacent_different(beg,end,dest)
adjacent_different(beg,end,dest,binaryOp)
iota(beg,end,val)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值