Explore the STL queue, a container adapter that implements a first-in, first-out queue based on another container.
- [Instructor] A queue is a container adaptor…which is like a wrapper that uses an underlying container…to hold its contents.…The queue implements a first in first out queue…where elements are pushed onto the back of the container…and then popped from the front.…Here I have a working copy of queue.cpp…from chapter two of the exercise files…and you'll notice that I include the queue header…which contains the queue type.…I'm also including the deque and list headers…because we're going to use those as underlying containers.…
Here we're creating a queue from a list…using the list as the underlying container.…So first I create a list and I initialize it…with an initializer list and then I construct a queue…from that list and so I list as the two parameters…to the template for the queue an integer type…and a list of integers type.…And then I pass the list to the constructor…and this constructs the queue.…And then I call report queue and report queue…just reports the size and the front and the back…because the queue is not a random access container…
- 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.