C++ · Intermediate level

Intermediate level · Module 3 of 6 · 16 guided hours

The Standard Template Library

Use STL containers, iterators and algorithms with lambdas to write shorter, faster and safer data-handling code.

Learning objectives

  • Choose the right container for a task
  • Use iterators and the standard algorithms
  • Write lambdas for custom predicates and comparisons

Topics

  • sequence containers: vector, deque
  • associative containers: map, set
  • unordered_map and unordered_set
  • iterators
  • algorithms: sort, find_if, count_if, transform, remove_if
  • lambdas and captures

Lessons

  1. Lesson 1 Choosing Containers

    Compare vector, map, set, unordered_map and unordered_set by ordering, uniqueness and lookup speed.

    std::vectorstd::map vs std::unordered_mapstd::setlookup complexity

  2. Lesson 2 Iterators and Algorithms

    Use iterators to connect containers to the standard algorithms for counting, searching, transforming and removing.

    iteratorfind_if / count_ifstd::transformstd::erase_if

  3. Lesson 3 Lambdas

    Write lambdas for predicates and comparisons, capture variables safely and sort by custom rules.

    lambda syntaxcapture by value and by referencecomparison for std::sortstd::tie

Practical activity

Analyse a list of market prices: count products, find the cheapest supplier per product with a map and list products whose price rose, using algorithms and lambdas.

Expected outcomes

  • Correct container choices
  • Concise data processing with algorithms

Assessment

Practical: implement five queries over a provided data set using containers and algorithms; marked by expected outputs.

Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.