deque::swap
두 deques의 요소를 교환합니다.
void swap(
deque<Type, Allocator>& _Right
);
friend void swap(
deque<Type, Allocator>& _Left,
deque<Type, Allocator>& _Right
)
template<class Type, class Allocator>
void swap(
deque< Type, Allocator>& _Left,
deque< Type, Allocator>& _Right
);
매개 변수
_Right
스왑 될 수 있는 요소를 제공 하는 있지 않은 deque 또는 요소가 인 들 여 있지 않은 deque를 교환 하는 있지 않은 deque _Left._Left
요소가 되는 있지 않은 deque 갖는 교환에 있지 않은 deque _Right.
예제
// deque_swap.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
int main( )
{
using namespace std;
deque <int> c1, c2, c3;
deque <int>::iterator c1_Iter;
c1.push_back( 1 );
c1.push_back( 2 );
c1.push_back( 3 );
c2.push_back( 10 );
c2.push_back( 20 );
c3.push_back( 100 );
cout << "The original deque c1 is:";
for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
cout << " " << *c1_Iter;
cout << endl;
c1.swap( c2 );
cout << "After swapping with c2, deque c1 is:";
for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
cout << " " << *c1_Iter;
cout << endl;
swap( c1,c3 );
cout << "After swapping with c3, deque c1 is:";
for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
cout << " " << *c1_Iter;
cout << endl;
swap<>(c1, c2);
cout << "After swapping with c2, deque c1 is:";
for ( c1_Iter = c1.begin( ); c1_Iter != c1.end( ); c1_Iter++ )
cout << " " << *c1_Iter;
cout << endl;
}
요구 사항
헤더: <deque>
네임 스페이스: std