std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: rbegin, std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>:: crbegin
From cppreference.net
<
cpp
|
container
|
flat multimap
|
reverse_iterator rbegin
(
)
noexcept
;
|
(1) |
(C++23以降)
(C++26以降 constexpr) |
|
const_reverse_iterator rbegin
(
)
const
noexcept
;
|
(2) |
(C++23以降)
(C++26以降 constexpr) |
|
const_reverse_iterator crbegin
(
)
const
noexcept
;
|
(3) |
(C++23以降)
(C++26以降 constexpr) |
反転された * this の最初の要素を指す逆方向イテレータを返します。これは非反転 * this の最後の要素に対応します。
* this が空の場合、返されるイテレータは rend() と等しくなります。
目次 |
戻り値
最初の要素への逆イテレータ。
計算量
定数。
注記
返される逆イテレータの 基盤イテレータ は 終端イテレータ です。したがって、終端イテレータが無効化された場合、返されるイテレータも無効化されます。
例
このコードを実行
#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 << "const reverse iteratorを使用して逆順で出力:\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: 非const値は変更可能 // map.crbegin()->second = 42; // エラー: const値は変更できません }
出力例:
const reverse iteratorを使用して逆順で出力:
{ "▓", 8 };
{ "▓", 7 };
{ "▒", 6 };
{ "▒", 5 };
{ "░", 4 };
{ "░", 3 };
{ "█", 2 };
{ "█", 1 };
関連項目
|
逆方向終端への逆方向イテレータを返す
(public member function) |
|
|
(C++14)
|
コンテナまたは配列の先頭への逆方向イテレータを返す
(function template) |