名前空間
変種
操作

std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::begin, std::unordered_multiset<Key,Hash,KeyEqual,Allocator>::cbegin

提供: cppreference.com
 
 
 
 
iterator begin() noexcept;
(C++11以上)
const_iterator begin() const noexcept;
(C++11以上)
const_iterator cbegin() const noexcept;
(C++11以上)

コンテナの最初の要素を指すイテレータを返します。

コンテナが空の場合は、返されたイテレータは end() と等しくなります。

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); // all cnt elements have equivalent keys
    }
}

出力例:

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

[編集] 関連項目

終端を指すイテレータを返します
(パブリックメンバ関数) [edit]