deque for char type : deque « deque « C++ Tutorial






#include <deque>
#include <iostream>


using namespace std;
typedef deque<char> CHARDEQUE;

void print_contents(CHARDEQUE deque, char*);

int main(void)
 {
   CHARDEQUE  a(3, 'A');    
   CHARDEQUE  b(4, 'B');    

   print_contents(a, "a");    
   print_contents(b, "b");
   a.swap(b);        
   print_contents(a, "a");
   print_contents(b, "b");
   a.swap(b);        
   print_contents(a, "a");
   print_contents(b, "b");
   a.assign(b.begin(),b.end());  
   print_contents(a, "a");
   a.assign(b.begin(),b.begin()+2);  
   print_contents(a, "a");
   a.assign(3, 'Z');      
   print_contents(a, "a");
 }

void print_contents(CHARDEQUE deque, char *name){
   CHARDEQUE::iterator pdeque;

   cout << "The contents of " << name << " : ";
   for(pdeque = deque.begin(); pdeque != deque.end(); pdeque++)
     cout << *pdeque << " ";
   cout<< endl;
}








22.1.deque
22.1.1.Use generic deque to store integers
22.1.2.deque for char type
22.1.3.Use generic deque to store chars
22.1.4.Use generic deque to store strings
22.1.5.Initialize deque with 26 copies of the letter x
22.1.6.Create another deque that contains a subrange of dq
22.1.7.create a deque
22.1.8.Use std::copy to print out all elements in a deque
22.1.9.deque.push_back( value )
22.1.10.deque.push_front( value )
22.1.11.Create your own stack based on deque
22.1.12.Constructing a Container with Values from the Standard Input
22.1.13.Combine insert and end to add elements to a deque