C++ Data StructuresLesson 52Free preview
C++ Deque
This lesson is part of C++ · All levels
Summary
Std::deque (double-ended queue) is a container that holds consecutive elements and allows addition and deletion at both ends at once. Unlike vectors that are only convenient at the back end, the deque provides push_front and push_back, plus random access through [] and at(). Because of its versatility, this deque is the basic container for stacks and queues.
Key points
- The deque supports push_front, push_back, pop_front, and pop_back.
- Deque still supports random access with operators [] and at().
- The addition in front doesn't have to shift the whole element like a vector.
- The built-in C++ queue and stack is built on top of the deck.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.