std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::end, std::flat_multimap<Key,T,Compare,KeyContainer,MappedContainer>::cend
来自 cppreference.cn
< cpp | 容器 | flat_multimap
iterator end() noexcept; |
(1) | (C++23 起) |
const_iterator end() const noexcept; |
(2) | (C++23 起) |
const_iterator cend() const noexcept; |
(3) | (C++23 起) |
返回指向 flat_multimap 中最后一个元素之后一个位置的迭代器。
此元素充当占位符;尝试访问它将导致未定义行为。
目录 |
[edit] 返回值
指向最后一个元素之后的迭代器。
[edit] 复杂度
常数时间。
[edit] 示例
运行此代码
#include <iostream> #include <flat_map> int main() { std::flat_multimap<int, int> map{{4, 13}, {9, 94}, {1, 19}, {4, 42}}; for (auto it = map.cbegin(); it != map.cend(); ++it) std::cout << '[' << it->first << "] = " << it->second << '\n'; // Unlike std::multimap's bidirectional iterators, the std::flat_multimap // iterators are random-access, so they can be used with the operator[]: auto it = map.cbegin(); assert(it[1] == 19); assert(it[4] == 13); assert(it[4] == 42); assert(it[9] == 94); }
输出
[1] = 19 [4] = 13 [4] = 42 [9] = 94
[edit] 参见
返回指向起始的迭代器 (public member function) | |
(C++11)(C++14) |
返回指向容器或数组末尾的迭代器 (function template) |