Aracılığıyla paylaş


hash_multimap::swap

[!NOT]

Bu API artık kullanılmıyor.Alternatif unordered_multimap Class.

İki hash_multimaps öğeleri değiştirir.

void swap(
   hash_multimap& _Right
);

Parametreler

  • _Right
    Takas öğeler sağlayan hash_multimap veya hash_multimap olanlar değiştirilebilmesi için öğeleri olan hash_multimap.

Notlar

Üye işlev yok başvuruları, işaretçileri veya öğeleri birbiriyle iki hash_multimaps öğeleri atamak yineleyiciler geçersiz kılar.

Visual C++ .NET 2003, üyeleri de <hash_map> ve <hash_set> başlık dosyaları artık std ad alanında bulunan, ancak bunun yerine stdext ad alanına taşınmış.Bkz: ad stdext daha fazla bilgi için.

Örnek

// hash_multimap_swap.cpp
// compile with: /EHsc
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_multimap <int, int> hm1, hm2, hm3;
   hash_multimap <int, int>::iterator hm1_Iter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 1, 10 ) );
   hm1.insert ( Int_Pair ( 2, 20 ) );
   hm1.insert ( Int_Pair ( 3, 30 ) );
   hm2.insert ( Int_Pair ( 10, 100 ) );
   hm2.insert ( Int_Pair ( 20, 200 ) );
   hm3.insert ( Int_Pair ( 30, 300 ) );

   cout << "The original hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout   << "." << endl;

   // This is the member function version of swap
   hm1.swap( hm2 );

   cout << "After swapping with hm2, hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout  << "." << endl;

   // This is the specialized template version of swap
   swap( hm1, hm3 );

   cout << "After swapping with hm3, hash_multimap hm1 is:";
   for ( hm1_Iter = hm1.begin( ); hm1_Iter != hm1.end( ); hm1_Iter++ )
      cout << " " << hm1_Iter -> second;
   cout   << "." << endl;
}
  
  
  

Gereksinimler

Başlık: <hash_map>

Ad alanı: stdext

Ayrıca bkz.

Başvuru

hash_multimap Class

Standart Şablon Kütüphanesi