hash_multimap::swap
![]() |
---|
Этот API устарел.Альтернативы unordered_multimap Class. |
Обменивает элементы 2 hash_multimaps.
void swap(
hash_multimap& _Right
);
Параметры
- _Right
Hash_multimap, предоставляющий элементы для передачи или hash_multimap, элементы которого следует обменянным одним из hash_multimap.
Заметки
Функция-член делает недействительной ссылки, указателей или итераторы, обозначенные элементы в 2 hash_multimaps элементы, которые обмениваются.
В Visual C++ .NET 2003 <hash_map> элементы файлов заголовков и <hash_set> больше не находятся в пространстве имен std, но скорее перейти на пространство имен stdext.Дополнительные сведения см. в разделе Пространство имен stdext.
Пример
// 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;
}
Требования
заголовок: <hash_map>
Stdext пространство имен: