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()

湖北22元/月(昔日数据)云服务器,国内湖北十堰云服务器,首月6折

昔日数据怎么样?昔日数据新上了湖北十堰云服务器,湖北十堰市IDC数据中心 母鸡采用e5 2651v2 SSD MLC企业硬盘 rdid5阵列为数据护航 100G高防 超出防御峰值空路由2小时 不限制流量。目前,国内湖北十堰云服务器,首月6折火热销售限量30台价格低至22元/月。(注意:之前有个xrhost.cn也叫昔日数据,已经打不开了,一看网站LOGO和名称为同一家,有一定风险,所以尽量不要选择...

TMThosting夏季促销:VPS月付7折,年付65折,独立服务器95折,西雅图机房

TMThosting发布了一个2021 Summer Sale活动,针对西雅图VPS主机提供月付7折优惠码,年付65折优惠码,独立服务器提供95折优惠码,本轮促销活动到7月25日。这是一家成立于2018年的国外主机商,主要提供VPS和独立服务器租用业务,数据中心包括美国西雅图和达拉斯,其中VPS基于KVM架构,都有提供免费的DDoS保护,支持选择Windows或者Linux操作系统。Budget ...

Virmach$7.2/年,新款月抛vps上线,$3.23/半年,/1核640M内存/10 GB存储/ 1Gbps/1T流量

Virmach自上次推出了短租30天的VPS后,也就是月抛型vps,到期不能续费,直接终止服务。此次又推出为期6个月的月抛VPS,可选圣何塞和水牛城机房,适合短期有需求的用户,有兴趣的可以关注一下。VirMach是一家创办于2014年的美国商家,支持支付宝、PayPal等方式,是一家主营廉价便宜VPS服务器的品牌,隶属于Virtual Machine Solutions LLC旗下!在廉价便宜美国...

algorithm为你推荐
公告格式通知格式范文提升网站排名怎么提高网站排名啊互联网接入计算机接入因特网的方式有哪几种宵云九宵云外.是什么意思组或资源的状态不是执行请求操作的正确状态无法启动承载网络,组或资源状态下不是执行请求操作的正确状态!网络地址分类A、B、C三类网络地址是如何划分的?请解释的通俗一点。化学键理论价键理论和分子轨道理论的主要区别是什么免费数据采集软件那个软件可以自动每天采集几十个网站的最新信息,并且发布信息到自己的门户网站上公司注册如何办理我想注册个小公司,具体怎么做。。。本地连接断开本地连接经常断开是怎么回事?
vps主机 域名网站 泛域名 北京租服务器 中国域名交易中心 韩国空间 精品网 域名优惠码 debian源 国内php空间 免费个人网站申请 ibox官网 ca4249 促正网秒杀 炎黄盛世 200g硬盘 卡巴斯基试用版 什么是服务器托管 1g空间 最好的qq空间 更多