A deque is declared in the same fashion 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 bidirectional iterators, as they do 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 data type, this is a much more restrictive condition than insertions into a list.
If the underlying element type provides a destructor, then the destructor will be invoked when a value is erased from a deque.
Since the deque data type 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 will permit a deque to hold many more elements than a vector.
As values are inserted, the index associated with any particular element in the collection will change. For example, if a value is inserted into position 3, then the value formerly indexed by 3 will now be found at index location 4, the value formerly at 4 will be found at index location 5, and so on.
©Copyright 1996, Rogue Wave Software, Inc.