The Standard Template Library

A cross-cutting module — the toolkit everything after this course assumes · ← Course home · Syllabus · Glossary

You have been building hand-made versions of this module’s contents all course long: the Box<T> was a vector, the Records module’s roster was a map waiting to happen, the Algorithms module’s maxOf was max_element. The STL is the professional, tested, generic version of every utility you hand-rolled — and this module teaches it by connecting each container to the hand-made one you already built, so nothing feels like new machinery, only better machinery.

Positioning: read after the Generics module (templates and contracts are the STL’s native language) and after Unit 15’s OOP module at minimum. Like the Generics module it sits outside the 16-unit week plan — but unlike it, this material is not optional for anyone continuing to data structures or real C++ work. It is the last stop before the Unit 16 capstone and its toolkit review.

What this module covers

Lesson What it covers
Lesson 1 — Sequence containers vector, array, deque, list, stack, queue, priority_queue — with the big choice table and the hand-made ancestors
Lesson 2 — Associative containers set, map, unordered_set, unordered_map — with the sorted-vs-hashed comparison tables and the when-to-use rules
Lesson 3 — Iterators, algorithms, lambdas Iterators as the glue; range-based loops; sort, find, count, reverse, min_element/max_element, accumulate; lambdas at an introductory level
Practice Exercises — 26 graded with separated solutions · Debugging — 10 seeded hunts · Challenges — 15 with separated solutions
Labs 6 labs — Contact manager, Inventory manager, Student grade analyzer, Frequency counter, Leaderboard, Task queue — one per major container family
Mini-project The Media Catalogue, professional edition — the Inheritance module’s design, re-hosted on STL containers

Prerequisites checklist

The module’s three ideas

  1. Containers are data structures with guarantees. Each one is a promise about where the fast operations are — the choice is engineering, not taste. Every table in this module is a promise table.
  2. Iterators are the glue. Half-open ranges [begin, end) — the same convention the search algorithms taught — let one algorithm serve every container.
  3. Algorithms replace loops. If a loop’s shape matches a named algorithm, the named version is shorter, less bug-prone, and says what it means — the DRY rule, library-wide.

— Engr. Dr. Muhammad Nadeem Majeed, Professor, Department of Data Science (PUCIT), University of the Punjab, Lahore · About the instructor