Javatpoint Logo
Javatpoint Logo

C++ multiset end()

C++ multiset end() function is used to return an iterator which is next to the last entry in the multiset.

Note:- This is a placeholder. No element exists in this location and attempting to access is undefined behavior.

Syntax

Parameter

None

Return value

It returns an iterator which is pointing next to the last element of the multiset.

Complexity

Constant.

Iterator validity

No changes.

Data Races

Concurrently accessing the elements of a multiset is safe.

The container is accessed neither the non-const nor the const versions modify the container.

Exception Safety

This member function never throws exception.

Example 1

Let's see the simple example for end() function:

Output:

C++
C++
Java
Java

In the above example, end() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Example 2

Let's see a simple example to iterate over the multiset using for-each loop:

Output:

0 0 1 1 2 2 5

Example 3

Let's see a simple example to iterate over the multiset using while loop:

Output:

Elements of mymultiset are: 
Aman
Deep
Deep
Nikita
Sonu

In the above example, end() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Example 4

Let's see a simple example:

Output:

Enter value to find: 60
Element not found.


Enter value to find: 20
Element found: 20

In the above example, end() function is used to return an iterator pointing next to the last element in the mymultiset multiset.

Next TopicC++ multiset





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA