From the course: C++ Templates and the STL

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Deque

Deque

- [Narrator] The deque container is unique in a few ways. It has the semantics of a vector but it's optimized as a double-ended queue, hence the name D-E queue, pronounced deck. So as to not confuse it with a verb about removing things from a queue. Here's a working copy of deque.cpp from chapter two of the exercise files. And you'll notice that the deque is defined in the deque header file. And here we have a simple deque container, much like our example for the vector. You can initialize it with initializer list and you can insert and delete anywhere. It has all the functionality of a vector, but where a vector is optimized for random access, a deque is optimized for rapid push and pop from its ends. And that's why it's the default container for stacks and queues, which we'll get to very soon here. So you can initialize it with initializer list or you can simply push elements on the back or on the front. I call report deque and print deque here. I'll go ahead and run this. Report…

Contents