Header Reference: <algorithm>
Header Reference: <algorithm>
Search, sort, partition, transform, set, and heap algorithms from the core STL algorithms header.
Header Reference: <algorithm>
Search, sort, partition, transform, set, and heap algorithms from the core STL algorithms header.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
Header reference pages are meant to answer a practical question quickly: what this header provides, when to reach for it, and which usage rules are easiest to get wrong.
<algorithm>find, find_if, count, all_of, any_of, none_ofsort, stable_sort, partial_sort, nth_elementcopy, move, transform, fill, replace, remove, uniquepartition, stable_partition, reverse, rotate, shufflemake_heap, push_heap, pop_heap, sort_heapset_union, set_intersection, set_difference, set_symmetric_difference, includestransform when you want an output sequence derived from an existing rangepartition and stable_partition when you want grouping without fully sorting#include <algorithm>
#include <vector>
int main() {
std::vector<int> values{5, 2, 5, 3, 1};
std::sort(values.begin(), values.end());
values.erase(std::unique(values.begin(), values.end()), values.end());
return std::binary_search(values.begin(), values.end(), 3) ? 0 : 1;
}
#include <algorithm>
#include <vector>
int main() {
std::vector<int> values{4, 1, 3, 2};
std::sort(values.begin(), values.end());
auto it = std::find(values.begin(), values.end(), 3);
return it == values.end() ? 1 : 0;
}