std::multiset<Key,Compare,Allocator>::rbegin, std::multiset<Key,Compare,Allocator>::crbegin
From cppreference.com
| reverse_iterator rbegin(); |
(1) | (C++11 以降 noexcept) |
| const_reverse_iterator rbegin() const; |
(2) | (C++11 以降 noexcept) |
| const_reverse_iterator crbegin() const noexcept; |
(3) | (C++11以降) |
逆順にされたmultisetの最初の要素へのリバースイテレータを返します。これは、逆順にされていないmultisetの最後の要素に対応します。multisetが空の場合、返されるイテレータはrend()と等しくなります。
目次 |
[編集] 戻り値
最初の要素へのリバースイテレータ。
[編集] 計算量
定数。
[編集] 注記
iterator と const_iterator の両方が定数イテレータであるため(実際には同じ型である可能性もあります)、これらのメンバ関数のいずれかによって返されたイテレータを通じてコンテナの要素を変更することはできません。
返されるリバースイテレータの基底イテレータは、endイテレータです。したがって、endイテレータが無効になった場合に、返されるイテレータも無効になります。
libc++はC++98モードにcrbegin()をバックポートしています。
[編集] 例
このコードを実行
#include <iostream> #include <set> int main() { std::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'; } }
出力
⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼ ⏼
[編集] 関連項目
| (C++11) |
末尾への逆イテレータを返す (public メンバ関数) |
| (C++14) |
コンテナまたは配列の先頭を指す逆順イテレータを返す (function template) |