unordered_set swap() function in C++ STL
The unordered_set::swap() method is a builtin function in C++ STL which is used to exchange values of two unordered_set containers. It swaps the element of two unordered_set containers. The sizes may differ but it swaps elements and changes the order of elements also.
Parameter: The function accepts one mandatory parameter second_name which specifies the second unordered_set which is to be swapped with the first one.
Return Value: This function doesn’t returns anything.
Below program illustrates the unordered_set::swap() function:
The elements of arr1 before swap(): 5 1 2 3 4 The elements of arr2 before swap(): 9 5 6 7 8 The elements of arr1 after swap(): 9 5 6 7 8 The elements of arr2 after swap(): 5 1 2 3 4