Containers and algorithms

This part of the C++ course is the standard library at work. An iterator is the interface every container shares, and an algorithm written once runs over all of them: find, count, transform, sort and binary search. Lambdas pass the comparison, std::map and std::set keep a key in order, and the adaptors wrap a container in a stack or a queue. The part ends with views, the numeric algorithms, a value that may be absent, one of several types, and the formatting that replaced a stream manipulator.

049 Iterators begin and end, iterator categories, ++ and *, const_iterator and std::distance Open 050 Algorithms find, count, any_of, transform and copy, and the difference between a loop and an algorithm Open 051 Sorting and searching sort, stable_sort, a custom comparator, lower_bound, binary_search and is_sorted Open 052 Lambda expressions capture by value and by reference, mutable lambdas, init captures and generic lambdas Open 053 Function objects and std::function a functor with state, std::function as a type-erased callable and the cost of the wrapper Open 054 std::map and std::unordered_map insert, find, operator[], iteration order, hashing and choosing between the two Open 055 std::set and std::unordered_set unique keys, insert and erase, set operations on sorted ranges and a visited set Open 056 deque, list and forward_list when a list beats a vector, splice, push_front and the memory each container spends Open 057 stack, queue and priority_queue the adaptor interface, the container underneath and a priority queue with a comparator Open 058 Ranges and views ranges::sort, views::filter, transform and take, and a lazy pipeline over a vector Open 059 Numeric algorithms accumulate, reduce, inner_product, iota and partial_sum in a running total Open 060 Tuples and pairs return two values, std::tie, structured bindings and std::apply Open 061 std::optional a value that may be absent, value_or, has_value, and a lookup that returns optional Open 062 std::variant one of several types, std::get, std::holds_alternative, std::visit and valueless_by_exception Open 063 std::format placeholders, format specifiers, alignment, numbers and a table built with std::format Open 064 std::print and std::println printing without iostream manipulators, formatting arguments, stdout and stderr Open

Lessons