Condividi tramite


hash_set::begin

[!NOTA]

Questo API è obsoleto.L'alternativa consiste unordered_set Class.

Restituisce un iteratore destinato al primo elemento in hash_set.

const_iterator begin( ) const; 
iterator begin( );

Valore restituito

Un iteratore bidirezionale destinato al primo elemento in hash_set o la posizione che gestisce un hash_set vuoto.

Note

Se il valore restituito begin viene assegnato a const_iterator, gli elementi nell'oggetto del hash_set non possono essere modificati.Se il valore restituito begin viene assegnato a iterator, gli elementi nell'oggetto del hash_set possono essere modificati.

In Visual C++ .NET 2003, i membri dei file di intestazione <hash_set> e <hash_map> non sono più nello spazio dei nomi di deviazione standard, ma sono stati spostati nello spazio dei nomi di stdext.Per ulteriori informazioni, vedere lo spazio dei nomi stdext.

Esempio

// hash_set_begin.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1;
   hash_set <int>::iterator hs1_Iter;
   hash_set <int>::const_iterator hs1_cIter;
   
   hs1.insert( 1 );
   hs1.insert( 2 );
   hs1.insert( 3 );

   hs1_Iter = hs1.begin( );
   cout << "The first element of hs1 is " << *hs1_Iter << endl;

   hs1_Iter = hs1.begin( );
   hs1.erase( hs1_Iter );

   // The following 2 lines would err because the iterator is const
   // hs1_cIter = hs1.begin( );
   // hs1.erase( hs1_cIter );

   hs1_cIter = hs1.begin( );
   cout << "The first element of hs1 is now " << *hs1_cIter << endl;
}
  

Requisiti

intestazione: <hash_set>

Stdext diSpazio dei nomi:

Vedere anche

Riferimenti

hash_set Class

Libreria di modelli standard