=====swap=====
Syntax:
#include
void swap( deque& from );
The swap() function exchanges the elements of the current deque with those of
from. This function operates in [[/complexity|constant time]].
For example, the following code uses the swap() function to exchange the values
of two deques:
deque v( 5, 1 );
deque d( 4, 42 );
v.swap( d );
size_t i;
cout << "v contains: ";
for( i = 0; i < v.size(); ++i ) cout << v[i] << ' ';
cout << '\n';
cout << "d contains: ";
for( i = 0; i < d.size(); ++i ) cout << d[i] << ' ';
cout << '\n';
The above code displays:
v contains: 42 42 42 42
d contains: 1 1 1 1 1
Related Topics: [[insert]], [[deque_operators|operator =]]