std::multiset<Key,Compare,Allocator>::begin, std::multiset<Key,Compare,Allocator>::cbegin
提供: cppreference.com
iterator begin(); |
(C++11未満) | |
iterator begin() noexcept; |
(C++11以上) | |
const_iterator begin() const; |
(C++11未満) | |
const_iterator begin() const noexcept; |
(C++11以上) | |
const_iterator cbegin() const noexcept; |
(C++11以上) | |
コンテナの最初の要素を指すイテレータを返します。
コンテナが空の場合は、返されたイテレータは end() と等しくなります。
引数
(なし)
戻り値
最初の要素を指すイテレータ。
計算量
一定。
ノート
iterator と const_iterator はどちらも定数イテレータである (実際には同じ型かもしれない) ため、これらのメンバ関数のいずれによって返されたイテレータを通してもコンテナの要素を変更することはできません。
例
Run this code
#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 cnt = words.count(*it);
std::cout << *it << ":\t" << cnt << '\n';
std::advance(it, cnt); // all cnt elements have equivalent keys
}
}
出力例:
come: 1
not: 1
out: 1
some: 1
sorted: 2
will: 1
words: 1
関連項目
| 終端を指すイテレータを返します (パブリックメンバ関数) |