Collections and algorithms
The collections are chosen by the work, not by habit. These twelve lessons sort and search, then compare the HashMap with the sorted BTreeMap, the sets, the deque, the list and the binary heap, and show what each one costs. The folds and the ranges come next, a pipeline of adaptors against a hand-written loop, and then the reading of real input: a line split and parsed, a text file read and written, a binary record, a walk over a directory and a CSV file whose bad line is reported with its number.
5.1
Sorting and searching
sort and sort_by, a custom ordering, binary_search, and a sorted insert that keeps the order (C++ 051)
Open
5.2
HashMap and BTreeMap
insert, get, the entry API, iteration order and the sorted map that keeps keys in order (C++ 054)
Open
5.3
HashSet and BTreeSet
unique values, insert and contains, set operations and a visited set in a graph walk (C++ 055)
Open
5.4
VecDeque, LinkedList and their cost
push_front on a deque, pop_back, when a list beats a vec, and the memory each one spends (C++ 056)
Open
5.5
BinaryHeap, stacks and queues
a max-heap, Reverse for a min-heap, a stack over a Vec and a queue over a VecDeque (C++ 057)
Open
5.6
fold, sum, product and scan
fold with an accumulator, sum and product, scan for a running total, and min and max (C++ 041, 059)
Open
5.7
Ranges and lazy sequences
Range and RangeInclusive, step_by, rev, and a chain that computes nothing until it is consumed (C++ 058)
Open
5.8
Splitting and parsing text
split, split_whitespace, parse with a type, FromStr, and a line of numbers turned into a Vec (C++ 065)
Open
5.9
Reading and writing text files
File and read_to_string, BufRead lines, create and write, and the errors a missing file returns (C++ 067)
Open
5.10
Bytes and binary files
read and write raw bytes, a length header, and why a struct needs a defined layout (C++ 068)
Open
5.11
Paths and directory walks
Path and PathBuf, join, create_dir_all, read_dir and a recursive walk (C++ 069)
Open
5.12
Parsing a file line by line
a CSV line split into fields, numbers converted, and the bad line reported with its number (C++ 070)
Open