Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
deque
comparison operators
deque::deque
deque::~deque
member functions:
deque::assign
deque::at
deque::back
deque::begin
deque::clear
deque::empty
deque::end
deque::erase
deque::front
deque::get_allocator
deque::insert
deque::max_size
deque::operator=
deque::operator[]
deque::pop_back
deque::pop_front
deque::push_back
deque::push_front
deque::rbegin
deque::rend
deque::resize
deque::size
deque::swap


deque::push_front

public member function
void push_front ( const T& x );

Insert element at beginning

Inserts a new element at the beginning of the deque container, right before its current first element. The content of this new element is initialized to a copy of x.

This effectively increases the container size by one.

Parameters

x
Value to be copied to the new element.
T is the first template parameter (the type of the elements stored in the container).

Return value

none

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// deque::push_front
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  deque<int> mydeque (2,100);     // two ints with a value of 100
  mydeque.push_front (200);
  mydeque.push_front (300);
  cout << "mydeque contains:";
  for (unsigned i=0; i<mydeque.size(); ++i)
    cout << " " << mydeque[i];
  cout << endl;
  return 0;
}


Output:
300 200 100 100 

Complexity

Constant.

See also