Deque is an optimized, basic sequence container for adding and removing operations to two segments of a sequence. It allows for faster random access, but it does not keep all objects in a contiguous block of memory like a vector, but instead uses multiple contiguous blocks of storage. Adding or removing elements to the Deque two segment is a small cost. It does not need to reallocate space, so adding elements to the end is more efficient than vector.
In fact, Deque is a combination of the pros and cons of vectors and lists, which is a container between the two.
Features of Deque:
1, random access convenience, that is, support [] and vector.at (), but the performance of the vector is not good.
2. Insert and delete operations can be done internally, but performance is less than list.
3. Push and pop can be performed at both ends.
4. Use more memory relative to vector.
Some basic uses of deque:
STL's Deque