Learn about the deque, a double-ended queue, which has all the functionality of a vector but is optimized for rapid push and pop operations.
- [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 deque gives it size in the front and back values…
- Template fundamentals
- STL containers
- Accessing iterators
- Output, forward, and bidirectional iterators
- The transform function
- Transforming strings and types
- Arithmetic, relational, and logical functions
- STL algorithms
Skill Level Intermediate
2. STL Containers
3. STL Iterators
5. STL Functions
6. STL Algorithm
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.