std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::rbegin, std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::crbegin
From cppreference.com
< cpp | コンテナ | flat_multimap
| 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_multimapの最初の要素への逆イテレータを返します。これは、通常の順序のflat_multimapの最後の要素に対応します。flat_multimapが空の場合、返されるイテレータはrend()と等しくなります。
目次 |
[編集] 戻り値
最初の要素へのリバースイテレータ。
[編集] 計算量
定数。
[編集] 注記
返される逆イテレータの基底となるイテレータは、endイテレータです。したがって、endイテレータが無効になった場合に、返されるイテレータも無効になります。
[編集] 例
このコードを実行
#include <algorithm> #include <iostream> #include <string> #include <flat_map> int main() { std::flat_multimap<std::string, int> map { {"█", 1}, {"▒", 5}, {"░", 3}, {"▓", 7}, {"▓", 8}, {"░", 4}, {"▒", 6}, {"█", 2} }; std::cout << "Print out in reverse order using const reverse iterators:\n"; std::for_each(map.crbegin(), map.crend(), [](std::pair<const std::string, int> const& e) { std::cout << "{ \"" << e.first << "\", " << e.second << " };\n"; }); map.rbegin()->second = 42; // OK: non-const value is modifiable // map.crbegin()->second = 42; // Error: cannot modify the const value }
実行結果の例
Print out in reverse order using const reverse iterators:
{ "▓", 8 };
{ "▓", 7 };
{ "▒", 6 };
{ "▒", 5 };
{ "░", 4 };
{ "░", 3 };
{ "█", 2 };
{ "█", 1 };[編集] 関連項目
| 末尾への逆イテレータを返す (public メンバ関数) | |
| (C++14) |
コンテナまたは配列の先頭を指す逆順イテレータを返す (function template) |