hash_multiset::swap
Exchanges the elements of two hash_multisets.
void swap(
hash_multiset& _Right
);
Parameters
- _Right
The argument hash_multiset providing the elements to be swapped with the target hash_multiset.
Remarks
The member function invalidates no references, pointers, or iterators that designate elements in the two hash_multisets whose elements are being exchanged.
In Visual C++ .NET 2003, members of the <hash_map> and <hash_set> header files are no longer in the std namespace, but rather have been moved into the stdext namespace. See The stdext Namespace for more information.
Example
// hash_multiset_swap.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multiset <int> hms1, hms2, hms3;
hash_multiset <int>::iterator hms1_Iter;
hms1.insert( 10 );
hms1.insert( 20 );
hms1.insert( 30 );
hms2.insert( 100 );
hms2.insert( 200 );
hms3.insert( 300 );
cout << "The original hash_multiset hms1 is:";
for ( hms1_Iter = hms1.begin( ); hms1_Iter != hms1.end( );
hms1_Iter++ )
cout << " " << *hms1_Iter;
cout << "." << endl;
// This is the member function version of swap
hms1.swap( hms2 );
cout << "After swapping with hms2, list hms1 is:";
for ( hms1_Iter = hms1.begin( ); hms1_Iter != hms1.end( );
hms1_Iter++ )
cout << " " << *hms1_Iter;
cout << "." << endl;
// This is the specialized template version of swap
swap( hms1, hms3 );
cout << "After swapping with hms3, list hms1 is:";
for ( hms1_Iter = hms1.begin( ); hms1_Iter != hms1.end( );
hms1_Iter++ )
cout << " " << *hms1_Iter;
cout << "." << endl;
}
The original hash_multiset hms1 is: 10 20 30.
After swapping with hms2, list hms1 is: 200 100.
After swapping with hms3, list hms1 is: 300.
Requirements
Header: <hash_set>
Namespace: stdext