public member type
<unordered_set>

std::unordered_multiset::end

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

The iterator returned by end does not point to any element, but to the position that follows the last element in the unordered_multiset container (its 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 [begin,end).

Notice that an unordered_multiset object makes no guarantees on how its elements with different values are ordered. But, in any case, the range that goes from its begin to its end covers all the elements in the container (or the bucket), until invalidated.

All iterators in an unordered_multiset have const access to the elements (even those whose type is not prefixed with const_): Elements can be inserted or removed, but not modified while in the container.

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 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

An iterator to the element past the end of the container (1) or the bucket (2).

All return types (iterator, const_iterator, local_iterator and const_local_iterator) are member types. In the unordered_multiset class template, these are forward iterator types.

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
// unordered_multiset::begin/end example
#include <iostream>
#include <string>
#include <unordered_set>

int main ()
{
  std::unordered_multiset<std::string> myums =
    {"father","mother","son","daughter","son","son"};

  std::cout << "myums contains:";
  for ( auto it = myums.begin(); it != myums.end(); ++it )
    std::cout << " " << *it;
  std::cout << std::endl;

  std::cout << "myums's buckets contain:\n";
  for ( unsigned i = 0; i < myums.bucket_count(); ++i) {
    std::cout << "bucket #" << i << " contains:";
    for ( auto local_it = myums.begin(i); local_it!= myums.end(i); ++local_it )
      std::cout << " " << *local_it;
    std::cout << std::endl;
  }

  return 0;
}

Possible output:
myums contains: father mother daughter son son son
myset's buckets contain:
bucket #0 contains:
bucket #1 contains: father
bucket #2 contains: mother
bucket #3 contains: daughter son son son
bucket #4 contains: 
bucket #5 contains: 
bucket #6 contains: 


Complexity

Constant.

Iterator validity

No changes.

See also