Module 5 · list and forward_list: When Elements Move and Positions Must Not
Every list and forward_list Operation, One by One, With Its Cost
Free with an accountReading
Bob has a list of scores and wants them in order. He writes what worked on every vector: sort(l.begin(), l.end());. GCC 12 answers with over twenty lines, all from inside the library's own files. Bob scrolls, sighs, and asks Amara what he broke. Nothing: a list sorts itself with l.sort(), and this lesson shows why, along with every other call and its cost.
Checking what this lesson needs for you…
What is inside Every list and forward_list Operation, One by One, With Its Cost
- list: making one, and assign
- list: push_back and push_front
- list: pop_back and pop_front
- list: front, back, size and empty
- list: insert
- list: erase
- list: clear and resize
- list: remove and remove_if
- list: unique
- list: sort, and why std::sort does not compile
- list: merge
- list: reverse
- list: splice in three formsIntermediate
- list: swap
- Moving an iterator: ++, --, next, prev, advance and distance
- forward_list: before_begin, insert_after and erase_after
- forward_list: push_front, pop_front, and no push_back or size
- forward_list: splice_after and the member algorithmsIntermediate
- Every cost in two tables, and one measured splice