首页 > 编程语言 >STL algorithm算法

STL algorithm算法

时间:2023-06-02 11:01:17浏览次数:48  
标签:function elements algorithm STL range element 算法 template sorted


Functions in <algorithm>

Non-modifying sequence operations:
all_of
Test condition on all elements in range (function template )
any_of
Test if any element in range fulfills condition (function template )
none_of
Test if no elements fulfill condition (function template )
for_each
Apply function to range (function template )
find
Find value in range (function template )
find_if
Find eleme

nt in range (function template )

find_if_not
Find element in range (negative condition) (function template )
find_end
Find last subsequence in range (function template )
find_first_of
Find element from set in range (function template )
adjacent_find
Find equal adjacent elements in range (function template )
count
Count appearances of value in range (function template )
count_if
Return number of elements in range satisfying condition (function template )
mismatch
Return first position where two ranges differ (function template )
equal
Test whether the elements in two ranges are equal (function template )
is_permutation
Test whether range is permutation of another (function template )
search
Search range for subsequence (function template )
search_n
Search range for elements (function template )

Modifying sequence operations:
copy
Copy range of elements (function template )
copy_n
Copy elements (function template )
copy_if
Copy certain elements of range (function template )
copy_backward
Copy range of elements backward (function template )
move
Move range of elements (function template )
move_backward
Move range of elements backward (function template )
swap
Exchange values of two objects (function template )
swap_ranges
Exchange values of two ranges (function template )
iter_swap
Exchange values of objects pointed by two iterators (function template )
transform
Transform range (function template )
replace
Replace value in range (function template )
replace_if
Replace values in range (function template )
replace_copy
Copy range replacing value (function template )
replace_copy_if
Copy range replacing value (function template )
fill
Fill range with value (function template )
fill_n
Fill sequence with value (function template )
generate
Generate values for range with function (function template )
generate_n
Generate values for sequence with function (function template )
remove
Remove value from range (function template )
remove_if
Remove elements from range (function template )
remove_copy
Copy range removing value (function template )
remove_copy_if
Copy range removing values (function template )
unique
Remove consecutive duplicates in range (function template )
unique_copy
Copy range removing duplicates (function template )
reverse
Reverse range (function template )
reverse_copy
Copy range reversed (function template )
rotate
Rotate left the elements in range (function template )
rotate_copy
Copy range rotated left (function template )
random_shuffle
Randomly rearrange elements in range (function template )
shuffle
Randomly rearrange elements in range using generator (function template )

Partitions:
is_partitioned
Test whether range is partitioned (function template )
partition
Partition range in two (function template )
stable_partition
Partition range in two - stable ordering (function template )
partition_copy
Partition range into two (function template )
partition_point
Get partition point (function template )

Sorting:
sort
Sort elements in range (function template )
stable_sort
Sort elements preserving order of equivalents (function template )
partial_sort
Partially sort elements in range (function template )
partial_sort_copy
Copy and partially sort range (function template )
is_sorted
Check whether range is sorted (function template )
is_sorted_until
Find first unsorted element in range (function template )
nth_element
Sort element in range (function template )

Binary search (operating on partitioned/sorted ranges):
lower_bound
Return iterator to lower bound (function template )
upper_bound
Return iterator to upper bound (function template )
equal_range
Get subrange of equal elements (function template )
binary_search
Test if value exists in sorted sequence (function template )

Merge (operating on sorted ranges):
merge
Merge sorted ranges (function template )
inplace_merge
Merge consecutive sorted ranges (function template )
includes
Test whether sorted range includes another sorted range (function template )
set_union
Union of two sorted ranges (function template )
set_intersection
Intersection of two sorted ranges (function template )
set_difference
Difference of two sorted ranges (function template )
set_symmetric_difference
Symmetric difference of two sorted ranges (function template )

Heap:
push_heap
Push element into heap range (function template )
pop_heap
Pop element from heap range (function template )
make_heap
Make heap from range (function template )
sort_heap
Sort elements of heap (function template )
is_heap
Test if range is heap (function template )
is_heap_until
Find first element not in heap order (function template )

Min/max:
min
Return the smallest (function template )
max
Return the largest (function template )
minmax
Return smallest and largest elements (function template )
min_element
Return smallest element in range (function template )
max_element
Return largest element in range (function template )
minmax_element
Return smallest and largest elements in range (function template )

Other:

lexicographical_compare
Lexicographical less-than comparison (function template )
next_permutation
Transform range to next permutation (function template )
prev_permutation
Transform range to previous permutation (function template )



标签:function,elements,algorithm,STL,range,element,算法,template,sorted
From: https://blog.51cto.com/u_16147764/6400871

相关文章

  • 算法学习day39动态规划part02-62、63
    packageLeetCode.DPpart02;/***62.不同路径*一个机器人位于一个mxn网格的左上角(起始点在下图中标记为“Start”)。*机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为“Finish”)。*问总共有多少条不同的路径?*示例:*输入......
  • 算法学习day41动态规划part03-343、96
    packageLeetCode.DPpart03;/***343.整数拆分*给定一个正整数n,将其拆分为k个正整数的和(k>=2),并使这些整数的乘积最大化。*返回你可以获得的最大乘积。*示例:*输入:n=2*输出:1*解释:2=1+1,1×1=1。**/publicclassIntegerBre......
  • 算法题——数组(一)
    1、两数之和给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target 的那 两个 整数,并返回它们的数组下标。/*建一个hash表,key存放值,value存放下标遍历数组,如果表里存在target-nums[i],则返回下标不存在则把当前的数存到hash表*/cl......
  • 算法之二分法、三元表达式、列表生成式、字典生成式(了解)、匿名函数、常见的内置函数
    算法之二分法二分概念二分算法,又称折半查找,即在一个单调有序的集合中查找一个解。每次分为左右两部分,判断解在哪个部分中并调整上下界,直到找到目标元素,每次二分后都将舍弃一半的查找空间。定义and实现:算法就是解决问题的高效办法常见的算法:二分法算法还可以锻炼我们的......
  • BouncyCastle
    任务详情在openEuler(推荐)或Ubuntu或Windows(不推荐)中完成下面任务参考附件内容完成SM2加解密的内容,提交运行结果截图(10‘)完成SM3,SM4算法的调用,提交运行结果截图和代码(15’,选做)jar包下载官网:https://www.bouncycastle.org/latest_releases.htmlbcprov-ext-jdk15to18-......
  • 文心一言 VS 讯飞星火 VS chatgpt (28)-- 算法导论5.1 3题
    三、假设你希望以1/2的概率输出0与1。你可以自由使用一个输出0或1的过程BIASED-RANDOM。它以某概率p输出1,概率1-p输出0,其中0<p<1,但是p的值未知。请给出一个利用BIASED-RANDOM作为子程序的算法,返回一个无偏的结果,能以概率1/2返回0,以概率1/2返回1。作为p的函数,你的算......
  • 文心一言 VS 讯飞星火 VS chatgpt (28)-- 算法导论5.1 3题
    三、假设你希望以1/2的概率输出0与1。你可以自由使用一个输出0或1的过程BIASED-RANDOM。它以某概率p输出1,概率1-p输出0,其中0<p<1,但是p的值未知。请给出一个利用BIASED-RANDOM作为子程序的算法,返回一个无偏的结果,能以概率1/2返回0,以概率1/2返回1。作为p的函数,你的......
  • 代码随想录算法训练营第二十二天|235. 二叉搜索树的最近公共祖先,701. 二叉搜索树中的
    [参考链接]235.二叉搜索树的最近公共祖先[注意]1.因为是有序树,所以如果中间节点是q和p的公共祖先,那么中间节点的数组一定是在[p,q]区间的。即中节点>p&&中节点<q或者中节点>q&&中节点<p。2.那么只要从上到下去遍历,遇到cur节点是数值在[p,q]区间中则一......
  • glibc堆内存分配算法
    对于小于64字节的空间申请是采用类似于对象池的方法;对于大于512字节的空间申请采用的是最佳适配算法;对于大于64字节而小于512字节的,它会根据情况采取上述办法中的最佳折中策略;对于大于128KB的申请,它会使用mmap机制直接向操作系统申请空间。 空闲链表(最佳适配算法)将堆中各个空......
  • 【数据集】 Bosch Small Traffic Lights Dataset(BSTLD)
    前言 参考1. GitHub-berktepebag/Traffic-light-detection-with-YOLOv3-BOSCH-traffic-light-dataset;2. BoschSmallTrafficLightsDataset;3. GitHub-bosch-ros-pkg/bstld:SamplescriptsfortheBoschSmallTrafficLightsDataset;4. ADeepLearningApproa......