an example of using C++ STL deque
deque is a double-ended queue
👍 g++ -std=c++11 deque.cpp && ./a.out
Cc Bb Aa Aa Bb Cc
👍 cat deque.cpp
#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main() {
vector<string> v{"Aa", "Bb", "Cc"};
deque<string> d;
for (const auto &s : v) {
d.push_front(s);
d.push_back(s);
}
for (const auto &e : d)
cout << e << ' ';
cout << endl;
}