A deque is declared the same way as a vector, and includes within the class the same type definitions as vector. The begin() and end() member functions return random access iterators, rather than the bidirectional iterators returned for lists.
An insertion -- either insert(), push_front(), or push_back() -- can potentially invalidate all outstanding iterators and references to elements in the deque. As with the vector datatype, this is a much more restrictive condition than insertions into a list.
If the underlying element type provides a destructor, the destructor is invoked when a value is erased from a deque.
Since the deque datatype provides random access iterators, all the generic algorithms that operate with vectors can also be used with deques.
A vector holds elements in a single large block of memory. A deque, on the other hand, uses a number of smaller blocks. This may be important on systems that restrict the size of memory blocks, as it permits a deque to hold many more elements than a vector.
As values are inserted, the index associated with any particular element in the collection changes. For example, if a value is inserted into position 3, the value formerly indexed by 3 is now found at index location 4; the value formerly at 4 is now found at index location 5, and so on.