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::deque

public member function
explicit deque ( const Allocator& = Allocator() );
explicit deque ( size_type n, const T& value= T(), const Allocator& = Allocator() );
template <class InputIterator>
         deque ( InputIterator first, InputIterator last, const Allocator& = Allocator() );
deque ( const deque<T,Allocator>& x );

Construct deque container

Constructs a deque container object, initializing its contents depending on the constructor version used:

explicit deque ( const Allocator& = Allocator() );
Default constructor: constructs an empty deque container, with no content and a size of zero.
explicit deque ( size_type n, const T& value= T(), const Allocator& = Allocator() );
Repetitive sequence constructor: Initializes the container with its content set to a repetition, n times, of copies of value.
template <class InputIterator> deque ( InputIterator first, InputIterator last, const Allocator& = Allocator() );
Iteration constructor: Iterates between first and last, setting a copy of each of the sequence of elements as the content of the container.
deque ( const deque<T,Allocator>& x );
Copy constructor: The deque container is initialized to have the same contents (copies) and properties as deque container x.

Parameters

n
Times that value is repeated to form the content of the container object.
Member type size_type is an unsigned integral type.
value
Value to be repeated n times as the content of the container object.
T is the first class template parameter (the type of the elements stored in the deque container).
first, last
Input iterators to the initial and final positions in a sequence. The range used is [first,last), which includes all the elements between first and last, including the element pointed by first but not the element pointed by last.
The function template type can be any type of input iterator.
x
Another deque object with the same class template parameters (T and Allocator).
unnamed Allocator parameter
Allocator object to be used instead of constructing a new one.
For class instantiations using their version of the default allocator class template, this parameter is not relevant.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// constructing deques
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  unsigned int i;
  // constructors used in the same order as described above:
  deque<int> first;                                // empty deque of ints
  deque<int> second (4,100);                       // four ints with value 100
  deque<int> third (second.begin(),second.end());  // iterating through second
  deque<int> fourth (third);                       // a copy of third
  // the iterator constructor can also be used to construct from arrays:
  int myints[] = {16,2,77,29};
  deque<int> fifth (myints, myints + sizeof(myints) / sizeof(int) );
  cout << "The contents of fifth are:";
  for (i=0; i < fifth.size(); i++)
    cout << " " << fifth[i];
  cout << endl;
  return 0;
}

Output:
The contents of fifth are: 16 2 77 29 

Complexity

For the default constructor, constant.
For the repetitive sequence constructor, linear on n (copy constructions).
For the iterator constructor, linear on the distance between the iterators (copy constructions).
For the copy constructor, linear on x's size (copy constructions).

See also