hash_multiset::swap (STL/CLR)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at hash_multiset::swap (STL/CLR).

Swaps the contents of two containers.

Syntax

void swap(hash_multiset<Key>% right);  

Parameters

right
Container to swap contents with.

Remarks

The member function swaps the controlled sequences between this and right. It does so in constant time and it throws no exceptions. You use it as a quick way to exchange the contents of two containers.

Example

// cliext_hash_multiset_swap.cpp   
// compile with: /clr   
#include <cliext/hash_set>   
  
typedef cliext::hash_multiset<wchar_t> Myhash_multiset;   
int main()   
    {   
    Myhash_multiset c1;   
    c1.insert(L'a');   
    c1.insert(L'b');   
    c1.insert(L'c');   
  
// display initial contents " a b c"   
    for each (wchar_t elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// construct another container with repetition of values   
    Myhash_multiset c2;   
    c2.insert(L'd');   
    c2.insert(L'e');   
    c2.insert(L'f');   
    for each (wchar_t elem in c2)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
// swap and redisplay   
    c1.swap(c2);   
    for each (wchar_t elem in c1)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
  
    for each (wchar_t elem in c2)   
        System::Console::Write(" {0}", elem);   
    System::Console::WriteLine();   
    return (0);   
    }  
  
a b c  
d e f  
d e f  
a b c  

Requirements

Header: <cliext/hash_set>

Namespace: cliext

See Also

hash_multiset (STL/CLR)
hash_multiset::operator= (STL/CLR)