public member function
<unordered_map>
std::unordered_map::cbegin
| container iterator (1) | const_iterator cbegin() const noexcept; |
|---|---|
| bucket iterator (2) | const_local_iterator cbegin ( size_type n ) const; |
Return const_iterator to beginning
A
const_iterator is an iterator that points to const content. This iterator can be increased and decreased (unless it is itself also const), just like the iterator returned by unordered_map::begin, but it cannot be used to modify the contents it points to.Parameters
- n
- Bucket number. This shall be lower than bucket_count.
It is an optional parameter that changes the behavior of this member function: if set, the iterator retrieved points to the first element of a bucket, otherwise it points to the first element of the container.
Member type size_type is an unsigned integral type.
Return Value
A const_iterator to the first element in the container (1) or the bucket (2).Both
const_iterator and const_local_iterator are member types. In the unordered_map class template, these are forward iterator types.const_local_iterator is an interator of the same category as const_iterator. Their value_type, difference_type, pointer and reference member types are also the same. But the iterators themselves are not necessarily of the same type.
Example
|
|
Possible output:
mymap contains: France:Paris Australia:Canberra U.S.:Washington mymap's buckets contain: bucket #0 contains: bucket #1 contains: bucket #2 contains: bucket #3 contains: bucket #4 contains: bucket #5 contains: France:Paris bucket #6 contains: bucket #7 contains: Australia:Canberra bucket #8 contains: U.S.:Washington bucket #9 contains: bucket #10 contains:
Complexity
Constant.Iterator validity
No changes.See also
- unordered_map::end
- Return iterator to end (public member function)
- unordered_map::cbegin
- Return const_iterator to beginning (public member function)
- unordered_map::operator[]
- Access element (public member function)