std::multimap<Key,T,Compare,Allocator>::rend, std::multimap<Key,T,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以降) |
逆順のmultimapの最後の要素の次を指す逆イテレータを返します。これは、通常の順序のmultimapの最初の要素の前の要素に対応します。この要素はプレースホルダーとして機能し、アクセスしようとすると未定義の動作が発生します。
目次 |
[編集] 戻り値
最後の要素の次の要素へのリバースイテレータ。
[編集] 複雑性
定数。
注釈
libc++はC++98モードにcrend()をバックポートしています。
[編集] 例
このコードを実行
#include <chrono> #include <iomanip> #include <iostream> #include <string_view> #include <map> using namespace std::chrono; int main() { const std::multimap<year_month_day, int> messages { {February/17/2023, 10}, {February/17/2023, 20}, {February/16/2022, 30}, {October/22/2022, 40}, {June/14/2022, 50}, {November/23/2021, 60}, {December/10/2022, 55}, {December/12/2021, 45}, {April/1/2020, 42}, {April/1/2020, 24} }; std::cout << "Messages received (date order is reversed):\n"; for (auto it = messages.crbegin(); it != messages.crend(); ++it) std::cout << it->first << " : " << it->second << '\n'; }
実行結果の例
Messages received (date order is reversed): 2023-02-17 : 20 2023-02-17 : 10 2022-12-10 : 55 2022-10-22 : 40 2022-06-14 : 50 2022-02-16 : 30 2021-12-12 : 45 2021-11-23 : 60 2020-04-01 : 24 2020-04-01 : 42
[編集] 関連項目
| (C++11) |
先頭への逆イテレータを返す (public メンバ関数) |
| (C++14) |
コンテナまたは配列の逆順の終端イテレータを返す (function template) |