std::ranges::is_sorted_until
来自cppreference.com
算法库
| 受约束算法及范围上的算法 (C++20) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 包含算法例如 ranges::copy, ranges::sort, ... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 执行策略 (C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 数值运算 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 在未初始化内存上的操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
受约束算法
本菜单中的所有名字均属于命名空间
std::ranges
| 不修改序列的操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 修改序列的操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 划分操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 排序操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 二分搜索操作(在有序范围上) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 集合操作(在有序范围上) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 堆操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 最小/最大操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 排列操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 折叠操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 未初始化存储上的操作 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 返回类型 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 在标头 <algorithm> 定义
|
||
| 调用签名 |
||
template< std::forward_iterator I, std::sentinel_for<I> S,
class Proj = std::identity,
std::indirect_strict_weak_order<std::projected<I, Proj>>
Comp = ranges::less >
constexpr I
is_sorted_until( I first, S last, Comp comp = {}, Proj proj = {} );
|
(1) | (C++20 起) |
template< std::forward_range R, class Proj = std::identity,
std::indirect_strict_weak_order<
std::projected<ranges::iterator_t<R>, Proj>>
Comp = ranges::less >
constexpr ranges::borrowed_iterator_t<R>
is_sorted_until( R&& r, Comp comp = {}, Proj proj = {} );
|
(2) | (C++20 起) |
检验范围 [first, last) 并寻找始于 first 且元素按非降序排序的最大范围。
若对于指向序列的任何迭代器 it 与使得 it + n 为指向序列元素的合法迭代器的任何非负整数 n,std::invoke(comp, std::invoke(proj, *(it + n)), std::invoke(proj, *it)) 求值为 false,则称序列相对于比较器 comp 有序。
1) 用给定的二元比较函数
comp 比较元素。2) 同 (1),但以
r 为源范围,如同以 ranges::begin(r) 为 first 并以 ranges::end(r) 为 last。此页面上描述的函数式实体是算法函数对象(非正式地称为 niebloid),即: