命名空间
变体
操作

std::flat_multiset<Key,Compare,KeyContainer>::rbegin, std::flat_multiset<Key,Compare,KeyContainer>::crbegin

来自 cppreference.cn
 
 
 
 
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_multiset 的首元素的逆向迭代器。它对应于非反向 flat_multiset 的最后一个元素。如果 flat_multiset 为空,则返回的迭代器等于 rend()

range-rbegin-rend.svg

目录

[编辑] 返回值

指向首元素的逆向迭代器。

[编辑] 复杂度

常数。

[编辑] 注解

由于 iteratorconst_iterator 均为常量迭代器(实际上可能为同一类型),因此无法通过这些成员函数返回的迭代器来修改容器的元素。

返回的逆向迭代器的底层迭代器end 迭代器。因此,当 end 迭代器失效时,返回的迭代器也会失效。

[编辑] 示例

#include <iostream>
#include <flat_set>
 
int main()
{
    std::flat_multiset<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';
    }
}

输出

⏼ ⏼ ⏼ ⏼
⏼ ⏼ ⏼ ⏼
⏼ ⏼ ⏼
⏼ ⏼ ⏼
⏼ ⏼
⏼ ⏼
⏼
⏼

[编辑] 参见

返回指向末尾的逆向迭代器
(public member function) [编辑]
返回指向容器或数组开头的逆向迭代器
(function template) [编辑]