std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::rend, std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::crend
來自 cppreference.com
< cpp | 容器 | flat_multimap
reverse_iterator rend() noexcept; |
(1) | (C++23 起) |
const_reverse_iterator rend() const noexcept; |
(2) | (C++23 起) |
const_reverse_iterator crend() const noexcept; |
(3) | (C++23 起) |
返回一個指向逆序 flat_multimap
中最後一個元素之後元素的逆序迭代器。它對應於非逆序 flat_multimap
中第一個元素之前的元素。此元素充當佔位符,嘗試訪問它會導致未定義行為。
目錄 |
[編輯] 返回值
指向最後一個元素之後位置的逆向迭代器。
[編輯] 複雜度
常數時間。
[編輯] 示例
執行此程式碼
#include <chrono> #include <iomanip> #include <iostream> #include <string_view> #include <flat_map> using namespace std::chrono; int main() { const std::flat_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
[編輯] 參閱
返回指向起始的逆向迭代器 (public member function) | |
(C++14) |
返回容器或陣列的反向結束迭代器 (function template) |