Namespaces
Variants

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

From cppreference.net

iterator begin ( ) noexcept ;
(1) (C++11부터)
(C++26부터 constexpr)
const_iterator begin ( ) const noexcept ;
(2) (C++11부터)
(C++26부터 constexpr)
const_iterator cbegin ( ) const noexcept ;
(3) (C++11부터)
(C++26부터 constexpr)

* this 의 첫 번째 요소에 대한 반복자를 반환합니다.

만약 * this 가 비어있다면, 반환된 반복자는 end() 와 같을 것입니다.

range-begin-end.svg

목차

반환값

첫 번째 요소에 대한 반복자.

복잡도

상수.

참고 사항

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 count = words.count(*it);
        std::cout << *it << ":\t" << count << '\n';
        std::advance(it, count); // all count elements have equivalent keys
    }
}

가능한 출력:

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

참고 항목

끝을 가리키는 반복자를 반환합니다
(public member function)
(C++11) (C++14)
컨테이너나 배열의 시작을 가리키는 반복자를 반환합니다
(function template)