std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::end, std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::cend

来自cppreference.com

 
 
容器库
序列
(C++11)
关联
无序关联
适配器
视图
(C++20)
 
 
iterator end() noexcept;
(C++11 起)
const_iterator end() const noexcept;
(C++11 起)
const_iterator cend() const noexcept;
(C++11 起)

返回指向 unordered_multiset 末元素后一元素的迭代器。

此元素表现为占位符;试图访问它导致未定义行为。

range-begin-end.svg

参数

(无)

返回值

指向后随最后元素的迭代器。

复杂度

常数。

注意

因为 iteratorconst_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 cnt = words.count(*it);
        std::cout << *it << ":\t" << cnt << '\n';
        std::advance(it, cnt); // 所有元素均拥有等价的键
    }
}

可能的输出:

some:   1
words:  2
to:     1
count:  2
these:  1

参阅

返回指向起始的迭代器
(公开成员函数)