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

CYUN专注海外精品服务器资源 国庆钜惠 最低5折起 限量促销

国庆钜惠 最低5折起 限量促销CYUN专注海外精品服务器资源,主营香港CN2 GIA、美国CERA、美国高防服务器资源,实体公司,ISP/IDC资质齐全,客服配备齐全。本次针对国庆推出非常给力的促销活动,旗下所有平台同享,新老客户同享,限时限量,售完截止。活动截止时间:2021年10月9日官网地址:www.cyun.net参与机型:香港CN2 GIA云服务器、香港双程CN2云服...

提速啦香港独立物理服务器E3 16G 20M 5IP 299元

提速啦(www.tisula.com)是赣州王成璟网络科技有限公司旗下云服务器品牌,目前拥有在籍员工40人左右,社保在籍员工30人+,是正规的国内拥有IDC ICP ISP CDN 云牌照资质商家,2018-2021年连续4年获得CTG机房顶级金牌代理商荣誉 2021年赣州市于都县创业大赛三等奖,2020年于都电子商务示范企业,2021年于都县电子商务融合推广大使。资源优势介绍:Ceranetwo...

hostkey荷兰/俄罗斯机房,GPU服务器

hostkey应该不用说大家都是比较熟悉的荷兰服务器品牌商家,主打荷兰、俄罗斯机房的独立服务器,包括常规服务器、AMD和Intel I9高频服务器、GPU服务器、高防服务器;当然,美国服务器也有,在纽约机房!官方网站:https://hostkey.com/gpu-dedicated-servers/比特币、信用卡、PayPal、支付宝、webmoney都可以付款!CPU类型AMD Ryzen9 ...

algorithm为你推荐
网络的好处关于网络的好处和坏处400字数字通信原理数字通信要怎么学方便快捷请问有什么方便快捷的方法除黑头it英语形式主语it的用法网络地址分类网络地址划分,急,测量师测量师考什么现在网现在网上有通过视频传病毒的,那是网站有毒还是播放器有毒还是视频有毒?2g内存条电脑里面的2G内存是做什么用的软件更新不可用手机软件突然更新不了怎么办等保测评机构什么是三级等保体系 three-level
看国外视频直播vps 免费动态域名 hostigation 2014年感恩节 美国便宜货网站 最好的空间 个人空间申请 河南m值兑换 1g内存 cn3 河南移动网 上海服务器 移动服务器托管 阿里云官方网站 贵阳电信 xuni 测速电信 免费个人网页 godaddy空间 服务器托管价格 更多