Udostępnij za pośrednictwem


hash_map::rbegin

[!UWAGA]

Ten interfejs API jest nieaktualny.Alternatywą jest unordered_map — Klasa.

Zwraca iterację adresowania pierwszym elementem hash_map odwrócone.

const_reverse_iterator rbegin( ) const; 
reverse_iterator rbegin( );

Wartość zwracana

Dwukierunkowy wstecznego sterująca adresowania pierwszym elementem hash_map odwrócone lub adresowania, co było ostatniego elementu w stałe hash_map.

Uwagi

rbeginjest używana z odwróconą hash_map po prostu jako rozpocząć jest używana z hash_map.

Jeśli wartość zwracaną przez rbegin jest przypisany do const_reverse_iterator, a następnie obiektu hash_map nie można modyfikować.Jeśli wartość zwracaną przez rbegin jest przypisany do reverse_iterator, a następnie obiekt hash_map mogą być modyfikowane.

rbeginmoże służyć do iteracji hash_map do tyłu.

W Visual C++ .NET 2003, elementy członkowskie plików nagłówka <hash_map> i <hash_set> nie są już w przestrzeni nazw std, ale raczej zostały przeniesione do przestrzeni nazw stdext.Zobacz Przestrzeń nazw stdext, aby uzyskać więcej informacji.

Przykład

// hash_map_rbegin.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.rbegin( );
   cout << "The first 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.rbegin( );
   hm1.erase ( hm1_rIter -> first );

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

Wymagania

Nagłówek: <hash_map>

Przestrzeń nazw: stdext

Zobacz też

Informacje

hash_map — Klasa

Standardowa biblioteka szablonów