规范库Range Copy算法留神: 必须要保障指标地位有足够的空间(resize 或者 reserve),规范算法在大多数状况下不能查看指标范畴是否足够大
copy(@beg, @end, @target_begin) -> @target_out copy_n(@beg, n, @target_begin) -> @target_out copy_backward(@beg, @end, @target_end) -> @target_begin (拷贝到end处)copy_if(@beg, @end, @target,f(O)->bool)->target_endsample(@beg, @end, @out, n, random_generator) ->out_end (实现采样-c++17)Special 迭代器感觉用途不大哦,除了插入这个interator规范库Sequence Reordering算法#shitf Elements 转换元素1.reserve/reserve_copy 反转2.rotate/rotate_copy 旋转 shift_left/shift_right(X感觉用途不大c++20)3.shuffle(@beg, @end, randim_engine) 随机打乱#sort 排序1.sort(@begin, @end, compare(o,o)->bool)2.stable_sort(@begin, @end, compare(o,o)->bool)//a.sort是疾速排序实现,因而是不稳固的;stable_sort是归并排序实现,因而是稳固的;//b.对于相等的元素sort可能扭转程序,stable_sort保障排序后相等的元素秩序不变//c.如果提供了比拟函数,sort不要求比拟函数的参数被限定为const,而stable_sort则要求参数被限定为const,否则编译不能通过3.partial_sort(@begin, n, @end, compare(o,o)->bool) /partial_sort_copy() nth_elements(没想到用处)4.is_sorted(@begin, @end, compare(o,o)->bool) -> true (是否有序)5.is_sorted_until(@begin, @end, compare(o,o)->bool) -> @sorted_end (返回到哪里之前是有序的)# partition 分区1.partition(@beg, @end, f(o,o)->bool) ->@ftrue_end 2.partition_copy(@beg, @end, @ft, @ff, f(O)->bool) -> {@ft_end, @ff_end}3.stable_partition(@beg, @end, f(o,o)->bool) ->@ftrue_end // stable_partition保障分区后原来的先后顺序不变,而partition无奈保障4.is_partition() -> true5.partition_point() -> @ftrue_end (分区后返回分界点)## Permutations 排列组合(不晓得利用场景??)1.next_permutation(@beg, @end) -> true 只有下一种排列能够是逻辑上大的,就返回true2.prev_permutataion(@beg, @end) -> true 只有上一种排列能够是逻辑上小的,就返回true3.is_permutation(@beg, @end, @beg2) -> true if range2 is a permutation of range1规范库Element-Wise Range Modifications(批改)# Filling / Overwriting Ranges 填充改写1.fill(@beg, @end, value) ->@filled_end (fill_n)2.generate(@begin ,@end generator()-> ●) (generator_n)//generator能够通过functors 写入不同的value,比fill性能强,不必循环这么捞的写了# Changing / Replacing Values 扭转代替1.transform(@beg, @end, @out, f(O)->■) -> @out_end2.transform(@beg, @end, @beg2, @out, f(O,△) -> ■) -> @out_end//该算法在其余编程语言中也称为"map"//target 必须可能承受和input range元素一样多的元素//f必须没有 side_effect / be stateful , 因为不能保障将functors利用于输出元素的程序3.replace(@beg, @end, old_value, new_value) / replace_if(@beg, @end, condition(O)->bool)4.replace_copy/replace_copy_if
...