The C++ standard specifies over 90 algorithms—many overloaded with two or more versions. The standard separates the algorithms into several categories—mutating sequence algorithms, nonmodifying sequence algorithms, sorting and related algorithms and generalized numeric operations. To learn about algorithms we did not present in this chapter, see your compiler’s documentation or visit sites such as
http://en.cppreference.com/w/cpp/algorithm
https://msdn.microsoft.com/library/yah1y2x8.aspx
Figure 16.16 shows many of the mutating-sequence algorithms—i.e., algorithms that modify the containers they operate on. Algorithms added in C++11 are marked with an * in Figs. 16.16–16.19. Algorithms presented in this chapter are shown in bold
.
<algorithm>
.Mutating sequence algorithms from header <algorithm> | |||
---|---|---|---|
copy |
copy_n* |
copy_if* |
copy_backward |
move* |
move_backward* |
swap |
swap_ranges |
iter_swap |
transform |
replace |
replace_if |
replace_copy |
replace_copy_if |
fill |
fill_n |
generate |
generate_n |
remove |
remove_if |
remove_copy |
remove_copy_if |
unique |
unique_copy |
reverse |
reverse_copy |
rotate |
rotate_copy |
random_shuffle |
shuffle* |
is_partitioned* |
partition |
stable_partition |
partition_copy* |
partition_point* |
|
Figure 16.17 shows the nonmodifying sequence algorithms—i.e., algorithms that do not modify the containers they operate on.
<algorithm>
Nonmodifying sequence algorithms from header <algorithm> |
|||
---|---|---|---|
all_of* |
any_of* |
none_of* |
for_each |
find |
find_if |
find_if_not* |
find_end |
find_first_of |
adjacent_find |
count |
count_if |
mismatch |
equal |
is_permutation* |
search |
search_n |
Figure 16.18 shows the sorting and related algorithms.
<algorithm>
Sorting and related algorithms from header <algorithm> |
|||
---|---|---|---|
sort |
stable_sort |
partial_sort |
partial_sort_copy |
is_sorted * |
is_sorted_until * |
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 |
is_heap* |
is_heap_until* |
min |
max |
minmax* |
min_element |
max_element |
minmax_element* |
lexicographical_compare |
next_permutation |
prev_permutation |
Figure 16.19 shows the numerical algorithms of the header <numeric>
.
Numerical algorithms from header <numeric> | |||
---|---|---|---|
accumulate |
partial_sum |
iota* |
|
inner_product |
adjacent_difference |