Compartir a través de


hash_map::rend

[!NOTA]

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

Devuelve un iterador que dirige la ubicación que funciona correctamente el último elemento en un hash_map invertido.

const_reverse_iterator rend( ) const; 
reverse_iterator rend( );

Valor devuelto

Un iterador bidireccional inversa que dirige la ubicación que funciona correctamente el último elemento en un hash_map invertido (la ubicación que había precedido el primer elemento del hash_map unreversed).

Comentarios

rend se utiliza con un hash_map invertido igual que final se utiliza con un hash_map.

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

rend se puede utilizar para probar a si un iterador inverso ha llegado al final del hash_map.

El valor devuelto por rend no debe ser administrada.

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_map_rend.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

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

   hash_map <int, int> :: iterator hm1_Iter;
   hash_map <int, int> :: reverse_iterator hm1_rIter;
   hash_map <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.rend( );
   hm1_rIter--;
   cout << "The last element of the reversed hash_map hm1 is "
        << hm1_rIter -> first << "." << endl;

   // begin can be used to start an iteration 
   // through a hash_map in a forward order
   cout << "The hash_map 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_map in a reverse order
   cout << "The reversed hash_map is: ";
   for ( hm1_rIter = hm1.rbegin( ) ; hm1_rIter != hm1.rend( );
      hm1_rIter++)
      cout << hm1_rIter -> first << " ";
      cout << "." << endl;

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

   hm1_rIter = hm1.rend( );
   hm1_rIter--;
   cout << "After the erasure, the last element "
        << "in the reversed hash_map is "
        << hm1_rIter -> first << "." << endl;
}
  
  
  
  

Requisitos

Encabezado: <hash_map>

Stdext deEspacio de nombres:

Vea también

Referencia

hash_map Class

Biblioteca de plantillas estándar