std::multiset<Key,Compare,Allocator>::end, std::multiset<Key,Compare,Allocator>::cend
出自cppreference.com
| |
(1) | (C++11 起為 noexcept) |
| |
(2) | (C++11 起為 noexcept) |
| |
(3) | (C++11 起) |
返回指向 multiset 末元素後一元素的迭代器。
此元素表現為占位符;試圖訪問它導致未定義行為。
返回值
指向後隨最後元素的迭代器。
複雜度
常數。
註解
因為 iterator 和 const_iterator 都是常迭代器(而且實際上可以是同一類型),故不可能通過任何這些成員函數返回的迭代器修改容器元素。
libc++ 將 cend() 向後移植到 C++98 模式。
示例
運行此代碼
#include <iostream>
#include <iterator>
#include <set>
#include <string>
int main()
{
const std::multiset<std::string> words =
{
"some", "not", "sorted", "words",
"will", "come", "out", "sorted",
};
for (auto it = words.begin(); it != words.end(); )
{
auto count = words.count(*it);
std::cout << *it << ":\t" << count << '\n';
std::advance(it, count); // 所有元素均拥有等价的键
}
}
輸出:
come: 1
not: 1
out: 1
some: 1
sorted: 2
will: 1
words: 1
參閱
(C++11) |
返回指向起始的迭代器 (公開成員函數) |
(C++11)(C++14) |
返回指向容器或數組結尾的迭代器 (函數模板) |