std::unordered_multiset<Key,Hash,KeyEqual,Allocator>:: begin, std::unordered_multiset<Key,Hash,KeyEqual,Allocator>:: cbegin
|
iterator begin
(
)
noexcept
;
|
(1) |
(seit C++11)
(constexpr seit C++26) |
|
const_iterator begin
(
)
const
noexcept
;
|
(2) |
(seit C++11)
(constexpr seit C++26) |
|
const_iterator cbegin
(
)
const
noexcept
;
|
(3) |
(seit C++11)
(constexpr seit C++26) |
Gibt einen Iterator zum ersten Element von * this zurück.
Wenn * this leer ist, wird der zurückgegebene Iterator gleich end() sein.
Inhaltsverzeichnis |
Rückgabewert
Iterator zum ersten Element.
Komplexität
Konstante.
Hinweise
Da sowohl
iterator
als auch
const_iterator
konstante Iteratoren sind (und tatsächlich derselbe Typ sein können), ist es nicht möglich, die Elemente des Containers über einen von diesen Memberfunktionen zurückgegebenen Iterator zu verändern.
Beispiel
#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 } }
Mögliche Ausgabe:
some: 1 words: 2 to: 1 count: 2 these: 1
Siehe auch
|
gibt einen Iterator zum Ende zurück
(öffentliche Elementfunktion) |
|
|
(C++11)
(C++14)
|
gibt einen Iterator zum Anfang eines Containers oder Arrays zurück
(Funktionstemplate) |