algorithmC++中<algorithm>这个头文件包含的所有函数有什么?

algorithm  时间:2021-08-22  阅读:()

通用库algorithm 有什么函数及具体功能

umulate sum up a range of elements adjacent_difference compute the differences between adjacent elements in a range adjacent_find finds two items that are adjacent to eachother binary_search determine if an element exists in a certain range copy copy some range of elements to a new location copy_backward copy a range of elements in backwards order copy_n copy N elements count return the number of elements matching a given value count_if return the number of elements for which a predicate is true equal determine if two sets of elements are the same equal_range search for a range of elements that are all equal to a certain element fill assign a range of elements a certain value fill_n assign a value to some number of elements find find a value in a given range find_end find the last sequence of elements in a certain range find_first_of search for any one of a set of elements find_if find the first element for which a certain predicate is true for_each apply a function to a range of elements generate saves the result of a function in a range generate_n saves the result of N applications of a function includes returns true if one set is a subset of another inner_product compute the inner product of two ranges of elements inplace_merge merge two ordered ranges in-place iota assign increasing values to a range of elements is_heap returns true if a given range is a heap is_sorted returns true if a range is sorted in ascending order iter_swap swaps the elements pointed to by two iterators pare returns true if one range is lexicographically less than another pare_3way determines if one range is lexicographically less than or greater than another lower_bound search for the first place that a value can be inserted while preserving order make_heap creates a heap out of a range of elements max returns the larger of two elements max_element returns the largest element in a range merge merge two sorted ranges min returns the smaller of two elements min_element returns the smallest element in a range mismatch finds the first position where two ranges differ next_permutation generates the next greater lexicographic permutation of a range of elements nth_element put one element in its sorted location and make sure that no elements to its left are greater than any elements to its right partial_sort sort the first N elements of a range partial_sort_copy copy and partially sort a range of elements partial_sum compute the partial sum of a range of elements partition divide a range of elements into two groups pop_heap remove the largest element from a heap power compute the value of some number raised to the Nth power prev_permutation generates the next smaller lexicographic permutation of a range of elements push_heap add an element to a heap random_sample randomly copy elements from one range to another random_sample_n sample N random elements from a range random_shuffle randomly re-order elements in some range remove remove elements equal to certain value remove_copy copy a range of elements omitting those that match a certian value remove_copy_if create a copy of a range of elements, omitting any for which a predicate is true remove_if remove all elements for which a predicate is true replace replace every urrence of some value in a range with another value replace_copy copy a range, replacing certain elements with new ones replace_copy_if copy a range of elements, replacing those for which a predicate is true replace_if change the values of elements for which a predicate is true reverse reverse elements in some range reverse_copy create a copy of a range that is reversed rotate move the elements in some range to the left by some amount rotate_copy copy and rotate a range of elements search search for a range of elements search_n search for N consecutive copies of an element in some range set_difference computes the difference between two sets set_intersection computes the intersection of two sets set_symmetric_difference computes the symmetric difference between two sets set_union computes the union of two sets sort sort a range into ascending order sort_heap turns a heap into a sorted range of elements stable_partition divide elements into two groups while preserving their relative order stable_sort sort a range of elements while preserving order between equal elements swap swap the values of two objects swap_ranges swaps two ranges of elements transform applies a function to a range of elements unique remove consecutive duplicate elements in a range unique_copy create a copy of some range of elements that contains no consecutive duplicates upper_bound searches for the last possible location to insert an element into an ordered range

#include <algorithm>有什么作用?

#include <algorithm>是一个头文件,该头文件包含了一些算法,程序开头加上这个头文件,就可以直接调用里面的函数了,不用再自己手写。

但是一些复杂的算法还是要自己写的。

另外可以看看这个 /reference/algorithm/

C++中<algorithm>这个头文件包含的所有函数有什么?

1)循环 对序列中的每个元素执行某项操作 for_each() 2)查找 在序列中找出某个值的第一次出现的位置 find(a,a+ size,n) 返回b 当b=a+size 即没找到,a为指针 在序列中找出符合某谓词的第一个元素 find_if() 在序列中找出一子序列的最后一次出现的位置 find_end() 在序列中找出第一次出现指定值集中之值的位置 find_first_of() 在序列中找出相邻的一对值 adjacent_find() 计数 在序列中统计某个值出现的次数 count() 在序列中统计与某谓词匹配的次数 count_if() 比较 找出两个序列相异的第一个元素 mismatch() 两个序列中的对应元素都相同时为真 在序列中找到等于某值的连续n次出现的位置 equal(a,a+n,b,cmp) equal_range(a,a+n,x) 搜索 在序列中找出一子序列的第一次出现的位置 search() 在序列中找出一值的连续n次出现的位置 search_n() 修改性序列操作(27个) 复制 从序列的第一个元素起进行复制 copy() 从序列的最后一个元素起进行复制 copy_backward() 交换 交换两个元素 swap() 交换指定范围的元素 swap_ranges() 交换由迭代器所指的两个元素 iter_swap() 变换 将某操作应用于指定范围的每个元素 transform() 替换 用一个给定值替换一些值 replace() 替换满足谓词的一些元素 replace_if() 复制序列时用一给定值替换元素 replace_copy() 复制序列时替换满足谓词的元素 replace_copy_if() 填充 用一给定值取代所有元素 fill() 用一给定值取代前n个元素 fill_n() 生成 用一操作的结果取代所有元素 generate() 用一操作的结果取代前n个元素 generate_n() 删除 删除具有给定值的元素 remove() 删除满足谓词的元素 remove_if() 复制序列时删除具有给定值的元素 remove_copy() 复制序列时删除满足谓词的元素 remove_copy_if() 唯一 删除相邻的重复元素 unique() 复制序列时删除相邻的重复元素 unique_copy() 反转 反转元素的次序 reverse(a,a+n) 复制序列时反转元素的次序 reverse_copy() 环移 循环移动元素 rotate(a,a+m,a+n) 以m位置为界交换前后序列 复制序列时循环移动元素 rotate_copy() 随机 采用均匀分布来随机移动元素 random_shuffle() 划分 将满足某谓词的元素都放到前面 partition() 将满足某谓词的元素都放到前面并维持原顺序 stable_partition() 序列排序及相关操作(27个) 排序 以很好的平均效率排序 sort(a,a+20,cmp) bool cmp( int a, int b ) { return a>b; } 在容器中或string用begin() 排序,并维持相同元素的原有顺序 stable_sort() 将序列的前一部分排好序 partial_sort() 复制的同时将序列的前一部分排好序 partial_sort_copy() 第n个元素 将第n各元素放到它的正确位置 nth_element() 二分检索 找到大于等于某值的第一次出现 lower_bound() 找到大于某值的第一次出现 upper_bound() 找到(在不破坏顺序的前提下)可插入给定值的最大范围 equal_range() 在有序序列中确定给定元素是否存在 binary_search() 归并 归并两个有序序列 merge() 归并两个接续的有序序列 inplace_merge() 有序结构上的集合操作 一序列为另一序列的子序列时为真 includes() 构造两个集合的有序并集 set_union() 构造两个集合的有序交集 set_intersection() 构造两个集合的有序差集 set_difference() 构造两个集合的有序对称差集(并-交) set_symmetric_difference() 堆操作 向堆中加入元素 push_heap() 从堆中弹出元素 pop_heap() 从序列构造堆 make_heap() 给堆排序 sort_heap() 最大和最小 两个值中较小的 min() 两个值中较大的 max() 序列中的最小元素 min_element(a,a+n) 序列中的最大元素 max_element() 词典比较 两个序列按字典序的第一个在前 pare() 排列生成器 按字典序的下一个排列 next_permutation() 按字典序的前一个排列 prev_permutation()

buyvm美国大硬盘VPS,1Gbps带宽不限流量

buyvm正式对外开卖第四个数据中心“迈阿密”的块存储服务,和前面拉斯维加斯、纽约、卢森堡一样,依旧是每256G硬盘仅需1.25美元/月,最大支持10T硬盘。配合buyvm自己的VPS,1Gbps带宽、不限流量,在vps上挂载块存储之后就可以用来做数据备份、文件下载、刷BT等一系列工作。官方网站:https://buyvm.net支持信用卡、PayPal、支付宝付款,支付宝付款用的是加元汇率,貌似...

HostKvm开年促销:香港国际/美国洛杉矶VPS七折,其他机房八折

HostKvm也发布了开年促销方案,针对香港国际和美国洛杉矶两个机房的VPS主机提供7折优惠码,其他机房业务提供8折优惠码。商家成立于2013年,提供基于KVM架构的VPS主机,可选数据中心包括日本、新加坡、韩国、美国、中国香港等多个地区机房,均为国内直连或优化线路,延迟较低,适合建站或者远程办公等。下面列出几款主机配置信息。美国洛杉矶套餐:美国 US-Plan1CPU:1core内存:2GB硬盘...

raksmart:全新cloud云服务器系列测评,告诉你raksmart新产品效果好不好

2021年6月底,raksmart开发出来的新产品“cloud-云服务器”正式上线对外售卖,当前只有美国硅谷机房(或许以后会有其他数据中心加入)可供选择。或许你会问raksmart云服务器怎么样啊、raksm云服务器好不好、网络速度快不好之类的废话(不实测的话),本着主机测评趟雷、大家受益的原则,先开一个给大家测评一下!官方网站:https://www.raksmart.com云服务器的说明:底层...

algorithm为你推荐
权限表什么是DRM权限列表,怎么使用距离查询汽车公里数怎么查看组或资源的状态不是执行请求操作的正确状态在输入netsh wlan start hostednetwork时,显示无法启动承载网络,组或资源的状态不是执行操作的正确状态余额宝收益走势图余额宝七日年化收益率走势图,哪个网站天天更新?直接能看到?网站数据分析报告网站要怎么去做分析报告?零终端如何打开android命令行终端软件更新不可用为什么我用流量更新软件更新不了请问是什么原因????信息发布管理系统信息发布系统属于建筑智能工程哪个分部hadoop大数据平台大数据集群?宽带包月宽带包年包月费是怎么回事
虚拟主机代理 香港加速器 fdcservers 骨干网络 godaddy域名证书 阿里云浏览器 200g硬盘 双11秒杀 免费网页申请 德讯 万网主机 国外代理服务器 hdchina 火山互联 tracert koss耳机 ftp服务器架设 广州服务器数据恢复 qq空间登入 灵动:鬼影实录3 更多