The object allocates and frees storage for the sequence it controls through a stored array of handles that designate blocks of Value elements. The array grows on demand. Growth occurs in such a way that the cost of either prepending or appending a new element is constant time, and no remaining elements are disturbed. You can also remove an element at either end in constant time, and without disturbing remaining elements. Thus, a deque is a good candidate for the underlying container for template class queue (STL/CLR) or template class stack (STL/CLR).
A deque object supports random-access iterators, which means you can refer to an element directly given its numerical position, counting from zero for the first (front) element, to deque::size (STL/CLR)() - 1 for the last (back) element. It also means that a deque is a good candidate for the underlying container for template class priority_queue (STL/CLR).
A deque iterator stores a handle to its associated deque object, along with the bias of the element it designates. You can use iterators only with their associated container objects. The bias of a deque element is not necessarily the same as its position. The first element inserted has bias zero, the next appended element has bias 1, but the next prepended element has bias -1.
Inserting or erasing elements at either end does not alter the value of an element stored at any valid bias. Inserting or erasing an interior element, however, can change the element value stored at a given bias, so the value designated by an iterator can also change. (The container may have to copy elements up or down to create a hole before an insert or to fill a hole after an erase.) Nevertheless, a deque iterator remains valid so long as its bias designates a valid element. Moreover, a valid iterator remains dereferencable -- you can use it to access or alter the element value it designates -- so long as its bias is not equal to the bias for the iterator returned by end().
Erasing or removing an element calls the destructor for its stored value. Destroying the container erases all elements. Thus, a container whose element type is a ref class ensures that no elements outlive the container. Note, however, that a container of handles does not destroy its elements.