hash_map::begin
[!UWAGA]
Ten interfejs API jest nieaktualny.Alternatywą jest unordered_map — Klasa.
Zwraca iterację adresowania pierwszym elementem hash_map.
const_iterator begin( ) const;
iterator begin( );
Wartość zwracana
Adresowanie pierwszym elementem hash_map lub lokalizacji kolejnego pustego hash_map sterująca dwukierunkowy.
Uwagi
Jeśli wartość zwracaną przez rozpocząć jest przypisany do const_iterator, nie można modyfikować elementów w obiekcie hash_map.Jeśli wartość zwracaną przez rozpocząć jest przypisany do sterująca, można modyfikować elementów w obiekcie hash_map.
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_begin.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> :: const_iterator hm1_cIter;
typedef pair <int, int> Int_Pair;
hm1.insert ( Int_Pair ( 0, 0 ) );
hm1.insert ( Int_Pair ( 1, 1 ) );
hm1.insert ( Int_Pair ( 2, 4 ) );
hm1_cIter = hm1.begin ( );
cout << "The first element of hm1 is "
<< hm1_cIter -> first << "." << endl;
hm1_Iter = hm1.begin ( );
hm1.erase ( hm1_Iter );
// The following 2 lines would err because the iterator is const
// hm1_cIter = hm1.begin ( );
// hm1.erase ( hm1_cIter );
hm1_cIter = hm1.begin( );
cout << "The first element of hm1 is now "
<< hm1_cIter -> first << "." << endl;
}
Wymagania
Nagłówek: <hash_map>
Przestrzeń nazw: stdext