multiset rbegin() and rend() function in C++ STL
- multiset::rbegin() is a built-in function in C++ STL which returns a reverse iterator pointing to the last element in the multiset container.
Syntax:
reverse_iterator multiset_name.rbegin()
Parameters: The function does not take any parameter.
Return value: The function returns a reverse iterator pointing to the last element in the container.
Below program illustrate the multiset::rbegin() method:
// CPP program to demonstrate the// multiset::rbegin() function#include <bits/stdc++.h>usingnamespacestd;intmain(){intarr[] = { 15, 12, 15, 11, 10, 10 };// initializes the set from an arraymultiset<int> s(arr, arr + 6);multiset<int>::reverse_iterator rit;// prints all elements in reverse orderfor(rit = s.rbegin(); rit != s.rend(); rit++)cout << *rit <<" ";cout <<"\nThe last element in multiset is "<< *(s.rbegin());return0;}chevron_rightfilter_noneOutput:15 15 12 11 10 10 The last element in multiset is 15
- multiset::rend() in an inbuilt function in C++ STL which returns a reverse iterator pointing to the theoretical element right before the first element in the multiset container.
Syntax:
reverse_iterator multiset_name.rend()
Parameter: The function does not accepts any parameter.
Return value: The function returns a reverse iterator pointing to the theoretical element right before the first element in the multiset container.
Below program illustrate the multiset::rend() function:
// CPP program to demonstrate the// multiset::rend() function#include <bits/stdc++.h>usingnamespacestd;intmain(){intarr[] = { 15, 13, 15, 11, 13, 10 };// initializes the set from an arraymultiset<int> s(arr, arr + 6);multiset<int>::reverse_iterator rit;// prints all elements in reverse orderfor(rit = s.rbegin(); rit != s.rend(); rit++)cout << *rit <<" ";return0;}chevron_rightfilter_noneOutput:15 15 13 13 11 10
Recommended Posts:
- vector rbegin() and rend() function in C++ STL
- list rbegin() and rend() function in C++ STL
- set::rbegin() and set::rend() in C++ STL
- array::rbegin() and array::rend() in C++ STL
- map rend() function in C++ STL
- map rbegin() function in C++ STL
- map rbegin() function in C++ STL
- deque rend() function in C++ STL
- deque rbegin() function in C++ STL
- multiset key_comp() function in C++ STL
- multiset begin() and end() function in C++ STL
- multiset get_allocator() function in C++ STL
- multiset count() function in C++ STL
- multiset find() function in C++ STL
- multiset equal_range() function in C++ STL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



