Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Latest commit

History

History
33 lines (25 loc) 路 805 Bytes

rbegin.md

File metadata and controls

33 lines (25 loc) 路 805 Bytes

rbegin

Description : It returns a reverse iterator which points to the last element of the map. The reverse iterator iterates in reverse order and incrementing it means moving towards beginning of map.

Example :

// C++ Program to illustrate map::rbegin() method 
#include <iostream> 
#include <map> 
  
int main() { 
  
    std::map<char, int> mp = { 
        { 'a', 1 }, 
        { 'b', 2 }, 
        { 'c', 3 }, 
        { 'd', 4 }, 
        { 'e', 5 }, 
    }; 
  
    std::cout << "Map contains following elements in reverse order"<< std::endl; 
    //rbegin 
    for (auto i = mp.rbegin(); i != mp.rend(); ++i) 
        std::cout << i->first 
             << " = " << i->second 
             << std::endl; 
  
    return 0; 
} 

Run Code