I always assumed deque implementations were ring buffers that double in size once full so that prepend/append operations are amortized O(1).
I always assumed deque implementations were ring buffers that double in size once full so that prepend/append operations are amortized O(1).
std::deque does have practical uses, but they're rare and many implementations aren't well suited even to those uses. Unlike VecDeque most people should just ignore it.
Why is that?
My major issue with std::deque is that the standard implementation doesn't provide a) a way to define the block size, b) a way to access the single blocks for optimizations. The deque in boost.container provides the former. I don't know if any widely available implementation provides the latter (segmented iterators were first proposed around the original C++ standardization, but it seems that were never picked up).
Maybe I just took the boxes-and-arrows diagrams from C++ books too seriously.
> When inserting at either end of the deque, references are not invalidated by insert and emplace.
> push_front, push_back, emplace_front and emplace_back do not invalidate any references to elements of the deque.