| |
One way to reverse-copy a deque. |
|
|
#include <iostream>
#include <deque>
using namespace std;
int main()
{
deque<char> dequeObject;
deque<char> reversedQueue;
int i;
for(i = 0; i <10; i++)
dequeObject.push_back('A'+i);
cout << "Contents of dequeObject: ";
for(i = 0; i <dequeObject.size(); i++)
cout << dequeObject[i];
cout << endl;
while(!dequeObject.empty()) {
reversedQueue.push_front(dequeObject.front());
dequeObject.pop_front();
}
cout << "Contents of reversedQueue: ";
for(i = 0; i <reversedQueue.size(); i++)
cout << reversedQueue[i];
return 0;
}
|
|
|
Related examples in the same category |
|