- C 标准库
- C 标准库
- C++ 标准库
- C++ 库 - 首页
- C++ 库 - <fstream>
- C++ 库 - <iomanip>
- C++ 库 - <ios>
- C++ 库 - <iosfwd>
- C++ 库 - <iostream>
- C++ 库 - <istream>
- C++ 库 - <ostream>
- C++ 库 - <sstream>
- C++ 库 - <streambuf>
- C++ 库 - <atomic>
- C++ 库 - <complex>
- C++ 库 - <exception>
- C++ 库 - <functional>
- C++ 库 - <limits>
- C++ 库 - <locale>
- C++ 库 - <memory>
- C++ 库 - <new>
- C++ 库 - <numeric>
- C++ 库 - <regex>
- C++ 库 - <stdexcept>
- C++ 库 - <string>
- C++ 库 - <thread>
- C++ 库 - <tuple>
- C++ 库 - <typeinfo>
- C++ 库 - <utility>
- C++ 库 - <valarray>
- C++ STL 库
- C++ 库 - <array>
- C++ 库 - <bitset>
- C++ 库 - <deque>
- C++ 库 - <forward_list>
- C++ 库 - <list>
- C++ 库 - <map>
- C++ 库 - <multimap>
- C++ 库 - <queue>
- C++ 库 - <priority_queue>
- C++ 库 - <set>
- C++ 库 - <stack>
- C++ 库 - <unordered_map>
- C++ 库 - <unordered_set>
- C++ 库 - <vector>
- C++ 库 - <algorithm>
- C++ 库 - <iterator>
- C++ 高级库
- C++ 库 - <any>
- C++ 库 - <barrier>
- C++ 库 - <bit>
- C++ 库 - <chrono>
- C++ 库 - <cinttypes>
- C++ 库 - <clocale>
- C++ 库 - <condition_variable>
- C++ 库 - <coroutine>
- C++ 库 - <cstdlib>
- C++ 库 - <cstring>
- C++ 库 - <cuchar>
- C++ 库 - <charconv>
- C++ 库 - <cfenv>
- C++ 库 - <cmath>
- C++ 库 - <ccomplex>
- C++ 库 - <expected>
- C++ 库 - <format>
- C++ 库 - <future>
- C++ 库 - <flat_set>
- C++ 库 - <flat_map>
- C++ 库 - <filesystem>
- C++ 库 - <generator>
- C++ 库 - <initializer_list>
- C++ 库 - <latch>
- C++ 库 - <memory_resource>
- C++ 库 - <mutex>
- C++ 库 - <mdspan>
- C++ 库 - <optional>
- C++ 库 - <print>
- C++ 库 - <ratio>
- C++ 库 - <scoped_allocator>
- C++ 库 - <semaphore>
- C++ 库 - <source_location>
- C++ 库 - <span>
- C++ 库 - <spanstream>
- C++ 库 - <stacktrace>
- C++ 库 - <stop_token>
- C++ 库 - <syncstream>
- C++ 库 - <system_error>
- C++ 库 - <string_view>
- C++ 库 - <stdatomic>
- C++ 库 - <variant>
- C++ STL 库速查表
- C++ STL - 速查表
C++ 库 - <algorithm>
算法介绍
algorithm 库提供了一些可用于各种用途的函数,例如搜索、排序、计数、操作等等。这些函数操作于元素范围,范围定义为[first, last)。
<algorithm> 中的函数
以下是 <algorithm> 头文件中所有方法的列表。
成员函数
| 序号 | 方法及描述 |
|---|---|
| 1 | algorithm::adjacent_find()
查找第一次出现的两个连续且相同的元素,如果存在连续的相同元素,则返回指向第一个元素的迭代器;否则返回指向最后一个元素的迭代器。 |
| 2 | algorithm::adjacent_find()
查找第一次出现的两个连续且相同的元素,如果存在连续的相同元素,则返回指向第一个元素的迭代器;否则返回指向最后一个元素的迭代器。 |
| 3 | algorithm::all_of()
如果谓词对从first到last. |
| 4 | 范围内的所有元素都返回 true,则返回 true。
如果谓词对从范围内任意元素返回truefirst到last. |
| 5 | algorithm::binary_search()
测试值是否存在于已排序的序列中。 |
| 6 | algorithm::binary_search()
测试值是否存在于已排序的序列中。 |
| 7 | algorithm::copy()
将一系列元素复制到新的位置。 |
| 8 | algorithm::copy_backward()
以反向顺序将一系列元素复制到新的位置。 |
| 9 | algorithm::copy_if()
如果谓词对值返回 true,则将一系列元素复制到新的位置。 |
| 10 | algorithm::copy_n()
复制前n个数字到新的位置。 |
| 11 | algorithm::count()
返回值在范围内的出现次数。 |
| 12 | algorithm::count_if()
返回满足条件的范围内值的出现次数。 |
| 13 | algorithm::equal()
测试两组元素是否相等。 |
| 14 | algorithm::equal()
测试两组元素是否相等。 |
| 15 | algorithm::equal_range()
返回与特定键匹配的元素范围。 |
| 16 | algorithm::equal_range()
返回与特定键匹配的元素范围。 |
| 17 | algorithm::fill()
为一系列元素赋值。 |
| 18 | algorithm::fill_n()
为由指向的序列的前 n 个元素赋值。first. |
| 19 | algorithm::fill_n()
为由指向的序列的前 n 个元素赋值。first. |
| 20 | algorithm::find()
查找元素的第一次出现。 |
| 21 | algorithm::find_end()
查找元素的最后一次出现。 |
| 22 | algorithm::find_end()
查找元素的最后一次出现。 |
| 23 | algorithm::find_first_of()
返回迭代器到范围内第一个元素(first1,last1)与first2,last2. |
| 24 | algorithm::find_first_of()
返回迭代器到范围内第一个元素(first1,last1)与first2,last2. |
| 25 | 中的任何元素匹配。
algorithm::find_if() |
| 26 | 查找满足条件的元素的第一次出现。
algorithm::find_if_not() |
| 27 | 查找不满足条件的元素的最后一次出现。
algorithm::for_each() |
| 28 | 将提供的函数应用于范围内的每个元素。
algorithm::generate()将对gen的连续调用返回的值赋值给从last. |
| 29 | first 到
algorithm::generate()将对范围内的元素。first. |
| 30 | first 到
algorithm::generate()将对范围内的元素。first. |
| 31 | algorithm::generate_n()
为由指向的序列的前 n 个元素赋值。 |
| 32 | algorithm::generate_n()
为由指向的序列的前 n 个元素赋值。 |
| 33 | algorithm::includes()
测试第一组是否为另一组的子集。 |
| 34 | algorithm::includes()
测试第一组是否为另一组的子集。 |
| 35 | algorithm::inplace_merge()
原位合并两个已排序的序列。 |
| 36 | algorithm::inplace_merge()
原位合并两个已排序的序列。 |
| 37 | algorithm::is_heap()
测试给定序列是否为最大堆。 |
| 38 | algorithm::is_heap()
测试给定序列是否为最大堆。 |
| 39 | algorithm::is_heap_until()
查找序列中第一个违反最大堆条件的元素。 |
| 40 | algorithm::is_partitioned()
测试范围是否已分区。 |
| 41 | algorithm::is_partitioned()
测试范围是否已分区。 |
| 42 | algorithm::is_permutation()
测试一个序列是否为另一个序列的排列。 |
| 43 | algorithm::is_permutation()
测试一个序列是否为另一个序列的排列。 |
| 44 | algorithm::is_sorted()
测试范围是否已排序。 |
| 45 | algorithm::is_sorted()
测试范围是否已排序。 |
| 46 | algorithm::is_sorted_until()
查找序列中第一个未排序的元素。 |
| 47 | algorithm::iter_swap()
交换两个迭代器指向的对象的值。 |
| 48 | algorithm::iter_swap()
交换两个迭代器指向的对象的值。 |
| 49 | algorithm::lexicographical_compare()
测试一个范围是否小于另一个范围(字典序)。 |
| 50 | algorithm::lexicographical_compare()
测试一个范围是否小于另一个范围(字典序)。 |