Learn C++ STL

Lesson 4 of 9 · stack and queue: Last In First Out, First In First Out

Module 6 · stack and queue: Last In First Out, First In First Out

When to Use stack, queue or a Plain vector, and When Not To

Free with an accountReading

Kenji writes every stack as a vector, because, he says, a vector is faster. Maria writes every line as a std::queue, and then her app has to show who is standing in the middle of it. Amara asks each of them one question: what did the job need? This lesson is her answer, with a chart, a flowchart and a measurement.

Checking what this lesson needs for you…

What is inside When to Use stack, queue or a Plain vector, and When Not To

  1. One question: who leaves first?
  2. The comparison chart
  3. The decision flowchart
  4. Kenji's claim, measured
  5. Why std::stack exists anyway
  6. When not to use either
  7. Recursion already uses a stack