Learn how to implement a regular queue with a deque.
- [Lecturer] Now, let's talk about…the queue container adapter.…Since the stack and the queue container adapters…are so similar, let me show you how to convert…the code of the stack we have just written…into the functionality of a queue.…So I will change some lines of code right now.…Let me change this first comment to queue,…and in line number five, I will change the header file…to the header file named queue.…
The next thing we need to change is in line number ten,…where we originally declared the stack.…Now, we will change this to a queue.…Everything else can stay the same…in the pushing round of insertions.…That is because a queue has the same push function…we can see here at line 18.…As for the printing part of the code,…here's what we'll change.…Line number 23 is referring to the top function,…but a queue does not have a top, queues have front,…and so, this is just a semantic issue,…but we have to change this to front,…which is where the elements come out of a queue.…
And there you have it, those are really…
- Why the STL is important
- Containers and iterators
- Vectors and lists
- Stacks and dequeues
- Associative containers
Skill Level Advanced
1. The Standard Template Library
2. Vectors and Lists
3. Stacks, Queues, and Deques
4. Associative Containers
- 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.