Description

The template class describes an object that controls a varying-length sequence of elements of type T. The sequence is represented in a way that permits insertion and removal of an element at either end with a single element copy (constant time). Such operations in the middle of the sequence require element copies and assignments proportional to the number of elements in the sequence (linear time).

The object allocates and frees storage for the sequence it controls through a stored allocator object of class A. Such an allocator object must have the same external interface as an object of template class allocator. Note that the stored allocator object is not copied when the container object is assigned.

Deque reallocation occurs when a member function must insert or erase elements of the controlled sequence:

  • If an element is inserted into an empty sequence, or if an element is erased to leave an empty sequence, then iterators earlier returned by begin() and end() become invalid.
  • If an element is inserted at first(), then all iterators but no references, that designate existing elements become invalid.
  • If an element is inserted at end(), then end() and all iterators, but no references, that designate existing elements become invalid.
  • If an element is erased at first(), only that iterator and references to the erased element become invalid.
  • If an element is erased at last() - 1, only that iterator, last(), and references to the erased element become invalid.
  • Otherwise, inserting or erasing an element invalidates all iterators and references.