次の方法で共有


map::crbegin

Returns a const iterator addressing the first element in a reversed map.

const_reverse_iterator crbegin( ) const;

Return Value

A const reverse bidirectional iterator addressing the first element in a reversed map Class or addressing what had been the last element in the unreversed map.

Remarks

crbegin is used with a reversed map just as map::begin is used with a map.

With the return value of crbegin, the map object cannot be modified

crbegin can be used to iterate through a map backwards.

Example

// map_crbegin.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;   
   map <int, int> m1;

   map <int, int> :: const_reverse_iterator m1_crIter;
   typedef pair <int, int> Int_Pair;

   m1.insert ( Int_Pair ( 1, 10 ) );
   m1.insert ( Int_Pair ( 2, 20 ) );
   m1.insert ( Int_Pair ( 3, 30 ) );

   m1_crIter = m1.crbegin( );
   cout << "The first element of the reversed map m1 is "
        << m1_crIter -> first << "." << endl;
}
The first element of the reversed map m1 is 3.

Requirements

Header: <map>

Namespace: std

See Also

Reference

map Class

Standard Template Library

Other Resources

map Members