STL之algorithm概述

from http://www.cplusplus.com/reference/algorithm/

Non-modifying sequence operations:

function name用法
all_ofTest condition on all elements in range
any_ofTest if any element in range fulfills condition
none_ofTest if no elements fulfill condition
for_eachApply function to range
findFind value in range
find_ifFind element in range
find_if_notFind element in range (negative condition)
find_endFind last subsequence in range
find_first_ofFind element from set in range
adjacent_findFind equal adjacent elements in range
countCount appearances of value in range
count_ifReturn number of elements in range satisfying condition
mismatchReturn first position where two ranges differ
equalTest whether the elements in two ranges are equal
is_permutationTest whether range is permutation of another
searchSearch range for subsequence
search_nSearch range for elements

Modifying sequence operations:

function name用法
copyCopy range of elements
copy_nCopy elements
copy_ifCopy certain elements of range
copy_backwardCopy range of elements backward
moveMove range of elements
move_backwardMove range of elements backward
swapExchange values of two objects
swap_rangesExchange values of two ranges
iter_swapExchange values of objects pointed to by two iterators
transformTransform range
replaceReplace value in range
replace_ifReplace values in range
replace_copyCopy range replacing value
replace_copy_ifCopy range replacing value
fillFill range with value
fill_nFill sequence with value
generateGenerate values for range with function
generate_nGenerate values for sequence with function
removeRemove value from range
remove_ifRemove elements from range
remove_copyCopy range removing value
remove_copy_ifCopy range removing values
uniqueRemove consecutive duplicates in range
unique_copyCopy range removing duplicates
reverseReverse range
reverse_copyCopy range reversed
rotateRotate left the elements in range
rotate_copyCopy range rotated left
random_shuffleRandomly rearrange elements in range
shuffleRandomly rearrange elements in range using generator

Partitions:

function name用法
is_partitionedTest whether range is partitioned
partitionPartition range in two
stable_partitionPartition range in two - stable ordering
partition_copyPartition range into two
partition_pointGet partition point

Sorting:

function name用法
sortSort elements in range
stable_sortSort elements preserving order of equivalents
partial_sortPartially sort elements in range
partial_sort_copyCopy and partially sort range
is_sortedCheck whether range is sorted
is_sorted_untilFind first unsorted element in range
nth_elementSort element in range

Binary search (operating on partitioned/sorted ranges):

function name用法
lower_boundReturn iterator to lower bound
upper_boundReturn iterator to upper bound
equal_rangeGet subrange of equal elements
binary_searchTest if value exists in sorted sequence

Merge (operating on sorted ranges):

function name用法
mergeMerge sorted ranges
inplace_mergeMerge consecutive sorted ranges
includesTest whether sorted range includes another sorted range
set_unionUnion of two sorted ranges
set_intersectionIntersection of two sorted ranges
set_differenceDifference of two sorted ranges
set_symmetric_differenceSymmetric difference of two sorted ranges

Heap:

function name用法
push_heapPush element into heap range
pop_heapPop element from heap range
make_heapMake heap from range
sort_heapSort elements of heap
is_heapTest if range is heap
is_heap_untilFind first element not in heap order

Min/max:

function name用法
minReturn the smallest
maxReturn the largest
minmaxReturn smallest and largest elements
min_elementReturn smallest element in range
max_elementReturn largest element in range
minmax_elementReturn smallest and largest elements in range

Other:

function name用法
lexicographical_compareLexicographical less-than comparison
next_permutationTransform range to next permutation
prev_permutationTransform range to previous permutation
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值