deque::push_back
將項目加入至雙向佇列的結尾。
void push_back(
const Type& _Val
);
void push_back(
Type&& _Val
);
參數
參數 |
說明 |
_Val |
項目加入雙向佇列的結尾。 |
備註
如果擲回例外狀況,雙向佇列保持不變,並重新擲回例外狀況。
程式碼範例
// deque_push_back.cpp
// compile with: /EHsc
#include <deque>
#include <iostream>
int main( )
{
using namespace std;
deque <int> d;
d.push_back( 1 );
d.push_back( 2 );
d.push_back( 3 );
for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
{
cout << *i << " ";
}
cout << endl;
d.push_front( 0 );
d.push_back( 4 );
for( deque<int>::const_iterator i = d.begin(); i != d.end(); ++i )
{
cout << *i << " ";
}
cout << endl;
// move initialize a deque of deques by moving d
deque < deque <int> > dd;
dd.push_back( move( d ) );
cout << "Moved last element: " << dd[0].back( ) << endl;
}
Output
1 2 3
0 1 2 3 4
Moved last element: 4
需求
標頭: <deque>
命名空間: std