Module 5 · list and forward_list: When Elements Move and Positions Must Not
When to Use list or forward_list, and Why the Answer Is Usually No
Free with an accountReading
Kenji keeps a price list sorted at all times. He reads that a list inserts in O(1), and a vector in O(n), so he moves his prices into a list. His program gets slower, about twenty times slower in the run below. Amara asks him one question: where did each new price go, and how did you find that place? This lesson is the answer, and for most programs it is "not in a list".
Checking what this lesson needs for you…
What is inside When to Use list or forward_list, and Why the Answer Is Usually No
- Six questions about your data
- The comparison chart
- The decision flowchart
- Kenji's prices: Stroustrup's experiment, small
- A table of iterators: Zara's bookmark bar
- Closing by a held position, measured
- forward_list: many short chains
- When the answer is no