std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::end, std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::cend
来自cppreference.com
< cpp | container | unordered multiset
iterator end() noexcept; |
(1) | (C++11 起) (C++26 起为 constexpr) |
const_iterator end() const noexcept; |
(2) | (C++11 起) (C++26 起为 constexpr) |
const_iterator cend() const noexcept; |
(3) | (C++11 起) (C++26 起为 constexpr) |
返回指向 *this 的尾后元素的迭代器。
返回的迭代器仅表现为哨位。不保证它可解引用。
目录 |
[编辑] 返回值
指向尾后元素的迭代器。
[编辑] 复杂度
常数。
注解
因为 iterator
和 const_iterator
都是常迭代器(而且实际上可以是同一类型),故不可能通过任何这些成员函数返回的迭代器修改容器元素。
[编辑] 示例
运行此代码
#include <iostream> #include <iterator> #include <string> #include <unordered_set> int main() { const std::unordered_multiset<std::string> words = { "some", "words", "to", "count", "count", "these", "words" }; for (auto it = words.begin(); it != words.end(); ) { auto count = words.count(*it); std::cout << *it << ":\t" << count << '\n'; std::advance(it, count); // 所有元素均拥有等价的键 } }
可能的输出:
some: 1 words: 2 to: 1 count: 2 these: 1
[编辑] 参阅
返回指向起始的迭代器 (公开成员函数) | |
(C++11)(C++14) |
返回指向容器或数组结尾的迭代器 (函数模板) |