首页 > 代码库 > deque

deque

#include <deque>
#include <iostream>
using namespace std;

int main(int argc, char *argv[])
{
    deque <int> A, B;

    deque <int> ::iterator it;

    A.push_front(1); B.push_back(1);
    A.push_front(2); B.push_back(2);
    A.push_front(3); B.push_back(3);

    A.pop_front(); B.pop_back();

    A.insert(A.begin(), 4);
    B.erase(B.begin());

    for (it = A.begin(); it != A.end(); it++)
        cout << *it << " ";
    cout << endl;

    for (it = B.begin(); it != B.end(); it++)
        cout << *it << " ";
    cout << endl;
    return 0;
}