std::flat_set<Key,Compare,KeyContainer>::rbegin, std::flat_set<Key,Compare,KeyContainer>::crbegin
来自cppreference.com
<tbody>
</tbody>
reverse_iterator rbegin() noexcept; |
(1) | (C++23 起) |
const_reverse_iterator rbegin() const noexcept; |
(2) | (C++23 起) |
const_reverse_iterator crbegin() const noexcept; |
(3) | (C++23 起) |
返回指向逆向的 flat_set 的首元素的逆向迭代器。它对应非逆向 flat_set 的末元素。如果 flat_set 为空,那么返回的迭代器等于 rend()。
返回值
指向首元素的逆向迭代器。
复杂度
常数。
注解
因为 iterator 和 const_iterator 都是常迭代器(而且实际上可以是同一类型),故不可能通过任何这些成员函数返回的迭代器修改容器元素。
返回的逆向迭代器的底层迭代器是尾迭代器。因此在尾迭代器失效时,返回的迭代器也会失效。
示例
运行此代码
#include <iostream>
#include <flat_set>
int main()
{
std::flat_set<unsigned> rep{1, 2, 3, 4, 1, 2, 3, 4};
for (auto it = rep.crbegin(); it != rep.crend(); ++it)
{
for (auto n = *it; n > 0; --n)
std::cout << "⏼" << ' ';
std::cout << '\n';
}
}
输出:
⏼ ⏼ ⏼ ⏼
⏼ ⏼ ⏼
⏼ ⏼
⏼
参阅
| 返回指向末尾的逆向迭代器 (公开成员函数) | |
(C++14) |
返回指向一个容器或数组的逆向迭代器 (函数模板) |