std::multiset<Key,Compare,Allocator>::rend, std::multiset<Key,Compare,Allocator>::crend
From cppreference.com
| reverse_iterator rend(); |
(1) | (C++11 以降 noexcept) |
| const_reverse_iterator rend() const; |
(2) | (C++11 以降 noexcept) |
| const_reverse_iterator crend() const noexcept; |
(3) | (C++11以降) |
逆順にソートされたmultisetの最後の要素の次の要素を指す逆イテレータを返します。これは、通常の順序のmultisetの最初の要素の前の要素に対応します。この要素はプレースホルダとして機能し、アクセスしようとすると未定義の動作が発生します。
目次 |
[編集] 戻り値
最後の要素の次の要素へのリバースイテレータ。
[編集] 複雑性
定数。
注釈
iterator と const_iterator の両方が定数イテレータであるため(実際には同じ型である可能性もあります)、これらのメンバ関数のいずれかによって返されたイテレータを通じてコンテナの要素を変更することはできません。
libc++はC++98モードにcrend()をバックポートしています。
[編集] 例
このコードを実行
#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) |