Compartir a través de


hash_multimap::rbegin

[!NOTA]

Esta API está obsoleta.La alternativa es unordered_multimap Class.

Devuelve un iterador que dirige el primer elemento de un hash_multimap invertido.

const_reverse_iterator rbegin( ) const; 
reverse_iterator rbegin( );

Valor devuelto

Un iterador bidireccional inversa que dirige el primer elemento de un hash_multimap o un direccionamiento invertido que había sido el último elemento del hash_multimap unreversed.

Comentarios

rbegin se utiliza con un hash_multimap invertido igual que inicio se utiliza con un hash_multimap.

Si el valor devuelto rbegin se asigna a const_reverse_iterator, el objeto de hash_multimap no puede modificarse.Si el valor devuelto rbegin se asigna a reverse_iterator, el objeto de hash_multimap puede modificarse.

rbegin se puede utilizar para iterar en un hash_multimap hacia atrás.

En Visual C++ .NET 2003, los miembros de los archivos de encabezado <hash_map> y <hash_set> ya no están en el espacio de nombres std, pero se han movido bastante al espacio de nombres stdext.Vea El espacio de nombres stdext para obtener más información.

Ejemplo

// hash_multimap_rbegin.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1;

   hash_multimap <int, int> :: iterator hm1_Iter;
   hash_multimap <int, int> :: reverse_iterator hm1_rIter;
   hash_multimap <int, int> :: const_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

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

   hm1_rIter = hm1.rbegin( );
   cout << "The first element of the reversed hash_multimap hm1 is "
        << hm1_rIter -> first << "." << endl;

   // begin can be used to start an iteration 
   // through a hash_multimap in a forward order
   cout << "The hash_multimap is: ";
   for ( hm1_Iter = hm1.begin( ) ; hm1_Iter != hm1.end( ); hm1_Iter++)
      cout << hm1_Iter -> first << " ";
      cout << "." << endl;

   // rbegin can be used to start an iteration 
   // through a hash_multimap in a reverse order
   cout << "The reversed hash_multimap is: ";
   for ( hm1_rIter = hm1.rbegin( ) ; hm1_rIter != hm1.rend( ); hm1_rIter++)
      cout << hm1_rIter -> first << " ";
      cout << "." << endl;

   // A hash_multimap element can be erased by dereferencing its key 
   hm1_rIter = hm1.rbegin( );
   hm1.erase ( hm1_rIter -> first );

   hm1_rIter = hm1.rbegin( );
   cout << "After the erasure, the first element"
        << "\n in the reversed hash_multimap is "
        << hm1_rIter -> first << "." << endl;
}
  
  
  
  

Requisitos

Encabezado: <hash_map>

Stdext deEspacio de nombres:

Vea también

Referencia

hash_multimap Class

Biblioteca de plantillas estándar