Algorithms library

< cpp

Contents

Non-modifying sequence operations
Defined in header <algorithm>
 all_ofany_ofnone_of (C++11)(C++11)(C++11)
checks if a predicate is true for all, any or none of the elements in a range
(function template)
 for_each
applies a function to a range of elements
(function template)
 countcount_if
returns the number of elements satisfying specific criteria
(function template)
 mismatch
finds the first position where two ranges differ
(function template)
 equal
determines if two sets of elements are the same
(function template)
 findfind_iffind_if_not (C++11)
finds the first element satisfying specific criteria
(function template)
 find_end
finds the last sequence of elements in a certain range
(function template)
 find_first_of
searches for any one of a set of elements
(function template)
finds two identical (or some other relationship) items adjacent to each other
(function template)
 search
searches for a range of elements
(function template)
 search_n
searches for a number consecutive copies of an element in a range
(function template)
Modifying sequence operations
Defined in header <algorithm>
 copycopy_if (C++11)
copies a range of elements to a new location
(function template)
 copy_n (C++11)
copies a number of elements to a new location
(function template)
 copy_backward
copies a range of elements in backwards order
(function template)
 move (C++11)
moves a range of elements to a new location
(function template)
 move_backward (C++11)
moves a range of elements to a new location in backwards order
(function template)
 fill
assigns a range of elements a certain value
(function template)
 fill_n
assigns a value to a number of elements
(function template)
 transform
applies a function to a range of elements
(function template)
 generate
saves the result of a function in a range
(function template)
 generate_n
saves the result of N applications of a function
(function template)
 removeremove_if
removes elements satisfying specific criteria
(function template)
 remove_copyremove_copy_if
copies a range of elements omitting those that satisfy specific criteria
(function template)
 replacereplace_if
replaces all values satisfying specific criteria with another value
(function template)
 replace_copyreplace_copy_if
copies a range, replacing elements satisfying specific criteria with another value
(function template)
 swap
swaps the values of two objects
(function template)
 swap_ranges
swaps two ranges of elements
(function template)
 iter_swap
swaps the elements pointed to by two iterators
(function template)
 reverse
reverses the order elements in a range
(function template)
 reverse_copy
creates a copy of a range that is reversed
(function template)
 rotate
rotates the order of elements in a range
(function template)
 rotate_copy
copies and rotate a range of elements
(function template)
 random_shuffleshuffle (C++11)
randomly re-orders elements in a range
(function template)
 unique
removes consecutive duplicate elements in a range
(function template)
 unique_copy
creates a copy of some range of elements that contains no consecutive duplicates
(function template)
Partitioning operations
 is_partitioned (C++11)
determines if the range is partitioned by the given predicate
(function template)
 partition
divides a range of elements into two groups
(function template)
 stable_partition
divides elements into two groups while preserving their relative order
(function template)
 partition_point (C++11)
locates the partition point of a partitioned range
(function template)
Sorting operations (on sorted ranges)
Defined in header <algorithm>
 is_sorted (C++11)
checks whether a range is sorted into ascending order
(function template)
 is_sorted_until (C++11)
finds the largest sorted subrange
(function template)
 sort
sorts a range into ascending order
(function template)
 partial_sort
sorts the first N elements of a range
(function template)
 partial_sort_copy
copies and partially sorts a range of elements
(function template)
 stable_sort
sorts a range of elements while preserving order between equal elements
(function template)
 nth_element
partially sorts the given range making sure that it is partitioned by the given element
(function template)
Binary search operations (on sorted ranges)
Defined in header <algorithm>
 lower_bound
returns an iterator to the first element not less than the given value
(function template)
 upper_bound
returns an iterator to the first element greater than a certain value
(function template)
 binary_search
determines if an element exists in a certain range
(function template)
 equal_range
returns range of elements matching a specific key
(function template)
Set operations (on sorted ranges)
Defined in header <algorithm>
 merge
merges two sorted ranges
(function template)
 inplace_merge
merges two ordered ranges in-place
(function template)
 includes
returns true if one set is a subset of another
(function template)
 set_difference
computes the difference between two sets
(function template)
 set_intersection
computes the intersection of two sets
(function template)
 set_symmetric_difference
computes the symmetric difference between two sets
(function template)
 set_union
computes the union of two sets
(function template)
Heap operations
Defined in header <algorithm>
 is_heap
checks if the given range is a heap
(function template)
 is_heap_until (C++11)
finds the largest subrange that is heap
(function template)
 make_heap
creates a heap out of a range of elements
(function template)
 push_heap
adds an element to a heap
(function template)
 pop_heap
removes the largest element from a heap
(function template)
 sort_heap
turns a heap into a sorted range of elements
(function template)
Minimum/maximum operations
Defined in header <algorithm>
 max
returns the larger of two elements
(function template)
 max_element
returns the largest element in a range
(function template)
 min
returns the smaller of two elements
(function template)
 min_element
returns the smallest element in a range
(function template)
 minmax (C++11)
returns the larger and the smaller of two elements
(function template)
 minmax_element (C++11)
returns the smallest and the largest element in a range
(function template)
 lexicographical_compare
returns true if one range is lexicographically less than another
(function template)
 is_permutation (C++11)
determines if a sequence is a permutation of another sequence
(function template)
 next_permutation
generates the next greater lexicographic permutation of a range of elements
(function template)
 prev_permutation
generates the next smaller lexicographic permutation of a range of elements
(function template)
Numeric operations
Defined in header <numeric>
 iota (C++11)
fills a range with successive increments of the starting value
(function template)
 accumulate
sums up a range of elements
(function template)
 inner_product
computes the inner product of two ranges of elements
(function template)