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:
Complexity
Constant.
See also
|