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

ProfitServer$34.56/年,西班牙vps、荷兰vps、德国vps/不限制流量/支持自定义ISO

profitserver怎么样?profitserver是一家成立于2003的主机商家,是ITC控股的一个部门,主要经营的产品域名、SSL证书、虚拟主机、VPS和独立服务器,机房有俄罗斯、新加坡、荷兰、美国、保加利亚,VPS采用的是KVM虚拟架构,硬盘采用纯SSD,而且最大的优势是不限制流量,大公司运营,机器比较稳定,数据中心众多。此次ProfitServer正在对德国VPS(法兰克福)、西班牙v...

日本美国站群服务器raksmart站群新增,限量低至月1.99美元

RAKsmart 商家八月份的促销活动今天更新。基本上和上个月的产品套餐活动差不多的,不过也是有简单的微调。对于RAKsmart商家还是比较了解的,他们家产品虽然这两年增加多个机房,以及在VPS主机方案上有丰富的机房和调整到一些自营机房,他们家的策划能力还是有限,基本上每个月的套餐活动都差不多。RAKsmart 在八月份看到有新增香港高防服务器可选,最高100GB防御。同时原来上个月缺货的日本独立...

腾讯云轻量应用服务器关于多个实例套餐带宽

腾讯云轻量应用服务器又要免费升级配置了,之前已经免费升级过一次了(腾讯云轻量应用服务器套餐配置升级 轻量老用户专享免费升配!),这次在上次的基础上再次升级。也许这就是良心云吧,名不虚传。腾讯云怎么样?腾讯云好不好。腾讯云轻量应用服务器 Lighthouse 是一种易于使用和管理、适合承载轻量级业务负载的云服务器,能帮助个人和企业在云端快速构建网站、博客、电商、论坛等各类应用以及开发测试环境,并提供...

algorithm为你推荐
社会网络分析社会网络关系移动开发移动应用开发好就业吗第三方接口支付宝第三方接口如何实现?提升网站排名怎么提高网站排名啊文件名长度文件名 过长 很长很长 如何更改文件名?宵云九宵云外.是什么意思化学键理论价键理论和分子轨道理论的主要区别是什么网通玩电信游戏卡怎么办玩英雄联盟家里是网通的,玩电信区很卡怎么办封包是什么洛克王国封包是什么意思最好的电脑操作系统电脑系统哪个比较好用,运行流畅?
域名备案 河北服务器租用 如何注册网站域名 如何查询ip地址 万网域名管理 科迈动态域名 warez 国外主机 账号泄露 512m内存 panel1 最好的免费空间 国外ip加速器 789 百度云加速 丽萨 vul 防cc攻击 阿里云手机官网 美国迈阿密 更多