STL講座
dequeのメンバ関数 insert

iが指す要素の直前にvalを挿入し、その要素を指す反復子を返す

iterator insert(iterator i, const T &val);

iが指す要素の直前にvalをnum個挿入する

void insert(iterator i, size_tyep num, const T &val);

iが指す要素の直前に、startからendで示されるシーケンスを挿入する

template<class Inlter> void insert(iterator i, inlter start, inlter end);

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

int main()
{
        deque<char> ob, ob2;
        int i;

        for(i=0; i<10; i++) {
                ob.push_back('a'+i);
                ob2.push_back('A'+i);
        }

        ob.insert(ob.begin() + 2, 'A');
        for(i=0; i<ob.size(); i++) cout << ob[i] << "  ";
        cout << endl;

        ob.insert(ob.begin() + 5, 2, 'B');
        for(i=0; i<ob.size(); i++) cout << ob[i] << "  ";
        cout << endl;

        ob.insert(ob.end(), ob2.begin(), ob2.end());
        for(i=0; i<ob.size(); i++) cout << ob[i] << "  ";

        return 0;
}

実行結果

a b A c d e f g h i j
a b A c d B B e f g h i j
a b A c d B B e f g h i j A B C D E F G H I J