public member function
<unordered_map>

std::unordered_multimap::cend

container iterator (1)
const_iterator cend() const noexcept;
bucket iterator (2)
const_local_iterator cend ( size_type n ) const;
Return const_iterator to end
Returns a const_iterator pointing to the past-the-end element in the unordered_multimap container (1) or in one of its buckets (2).

The const_iterator returned by cend does not point to any element, but to the position that follows the last element in the unordered_multimap container or in one of its buckets (i.e., their past-the-end position). Thus, the value returned shall not be dereferenced - it is generally used to describe the open-end of a range, such as [cbegin,cend).

Notice that an unordered_multimap object makes no guarantees on which order its elements follow. But, in any case, the range that goes from its cbegin to its cend covers all the elements in the container (or the bucket), until invalidated.

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_multimap::end, 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 const_iterator retrieved points to the past-the-end element of a bucket, otherwise it points to the past-the-end element of the container.
Member type size_type is an unsigned integral type.

Return Value

A const_iterator to the element past the end of the container (2) or the bucket (2).

Both const_iterator and const_local_iterator are member types. In the unordered_multimap 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// unordered_multimap::cbegin/cend example
#include <iostream>
#include <unordered_map>

int main ()
{
  std::unordered_multimap<std::string,std::string> myumm = {
    {"apple","red"},
    {"apple","green"},
    {"orange","orange"},
    {"strawberry","red"}
  };

  std::cout << "myumm contains:";
  for ( auto it = myumm.cbegin(); it != myumm.cend(); ++it )
    std::cout << " " << it->first << ":" << it->second;  // cannot modify *it
  std::cout << std::endl;

  std::cout << "myumm's buckets contain:\n";
  for ( unsigned i = 0; i < myumm.bucket_count(); ++i) {
    std::cout << "bucket #" << i << " contains:";
    for ( auto local_it = myumm.cbegin(i); local_it!= myumm.cend(i); ++local_it )
      std::cout << " " << local_it->first << ":" << local_it->second;
    std::cout << std::endl;
  }

  return 0;
}


Possible output:
myumm contains: apple:red apple:green orange:orange strawberry:red
myumm's buckets contain:
bucket #0 contains:
bucket #1 contains:
bucket #2 contains: apple:red apple:green
bucket #3 contains: orange:orange
bucket #4 contains: strawberry:red

Complexity

Constant.

Iterator validity

No changes.

See also

<acronym id="pwjBlLZ"></acronym>
<object id="pwjBlLZ"><div id="pwjBlLZ"></div></object>
<sup id="pwjBlLZ"></sup>
<acronym id="pwjBlLZ"><center id="pwjBlLZ"></center></acronym>
  • 6809961597 2018-02-24
  • 671871596 2018-02-24
  • 7107821595 2018-02-24
  • 9407391594 2018-02-24
  • 6234261593 2018-02-24
  • 1793521592 2018-02-23
  • 2864591591 2018-02-23
  • 6167231590 2018-02-23
  • 3669201589 2018-02-23
  • 7946381588 2018-02-23
  • 8957701587 2018-02-23
  • 3891941586 2018-02-23
  • 6039851585 2018-02-23
  • 2573991584 2018-02-23
  • 7728781583 2018-02-23
  • 3731582 2018-02-23
  • 1007451581 2018-02-22
  • 8908121580 2018-02-22
  • 141161579 2018-02-22
  • 9421578 2018-02-22