deque.push_front( value ) : deque « Deque « C++






deque.push_front( value )

  
 
#include <iostream>
using std::cout;
using std::endl;

#include <deque>     // deque class-template definition
#include <algorithm> // copy algorithm
#include <iterator>  // ostream_iterator

int main()
{
   std::deque< double > values; // create deque of doubles
   std::ostream_iterator< double > output( cout, " " );

   values.push_front( 2.2 );
   values.push_front( 3.5 );
   values.push_back( 1.1 );

   cout << "values contains: ";
   // use subscript operator to obtain elements of values
   for ( int i = 0; i < values.size(); i++ )
      cout << values[ i ] << ' ';
   cout << endl;
   return 0;
}

/* 
values contains: 3.5 2.2 1.1

 */        
    
  








Related examples in the same category

1.Use generic deque to store integers
2.Use generic deque to store chars
3.Use generic deque to store strings
4.Initialize deque with 26 copies of the letter x
5.create a deque
6.Use std::copy to print out all elements in a deque
7.deque.push_back( value )
8.Create your own stack based on deque
9.Combine insert and end to add elements to a deque
10.Save transformed data from vector to deque (Vector1 + Vector2 = Result (in Deque))