std::multiset<Key,Compare,Allocator>:: begin, std::multiset<Key,Compare,Allocator>:: cbegin
From cppreference.net
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::multiset
| Member functions | |||||||||||||||||||||||||||
| Non-member functions | |||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||
| Deduction guides (C++17) | |||||||||||||||||||||||||||
|
iterator begin
(
)
;
|
(1) |
(C++11부터 noexcept)
(C++26부터 constexpr) |
|
const_iterator begin
(
)
const
;
|
(2) |
(C++11부터 noexcept)
(C++26부터 constexpr) |
|
const_iterator cbegin
(
)
const
noexcept
;
|
(3) |
(C++11부터)
(C++26부터 constexpr) |
* this 의 첫 번째 요소에 대한 반복자를 반환합니다.
만약 * this 가 비어있는 경우, 반환된 iterator는 end() 와 같을 것입니다.
목차 |
반환값
첫 번째 요소에 대한 반복자.
복잡도
상수.
참고 사항
iterator
와
const_iterator
모두 상수 반복자이므로(실제로 동일한 타입일 수 있음), 이러한 멤버 함수들이 반환하는 반복자를 통해 컨테이너 요소들을 변경하는 것은 불가능합니다.
libc++ 백포트는
cbegin()
를 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); // all count elements have equivalent keys } }
출력:
come: 1 not: 1 out: 1 some: 1 sorted: 2 will: 1 words: 1
참고 항목
|
(C++11)
|
끝을 가리키는 반복자를 반환함
(public member function) |
|
(C++11)
(C++14)
|
컨테이너나 배열의 시작을 가리키는 반복자를 반환함
(function template) |