hash_multimap::begin

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_multimap Class

傳回位址的 Iterator。hash_multimap 的第一個項目。

const_iterator begin( ) const; 
iterator begin( );

傳回值

解決雙向的 Iterator 為空白 hash_multimap 的 hash_multimap 的第一個項目或位置。

備註

如果的傳回值指派給 const_iteratorbegin ,無法修改 hash_multimap 物件的項目。 如果傳回值 begin 指派給 iterator,可以修改 hash_multimap 物件的項目。

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。 如需詳細資訊,請參閱 stdext 命名空間

範例

// hash_multimap_begin.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> :: 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;
}
  
  

需求

標題: <hash_map>

命名空間: stdext

請參閱

參考

hash_multimap Class

標準樣板程式庫