std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::begin, std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::cbegin - cppreference.com
提供: cppreference.com
<tbody> </tbody>
|
|
(C++11以上) | |
|
|
(C++11以上) | |
|
|
(C++11以上) | |
コンテナの最初の要素を指すイテレータを返します。
コンテナが空の場合は、返されたイテレータは end() と等しくなります。
引数
(なし)
戻り値
最初の要素を指すイテレータ。
計算量
一定。
ノート
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 cnt = words.count(*it); std::cout << *it << ":\t" << cnt << '\n'; std::advance(it, cnt); // all cnt elements have equivalent keys } }
出力例:
some: 1 words: 2 to: 1 count: 2 these: 1