Card 10/ 10
Recap: Streams
Laziness, pulling one element at a time, map and flatMap, collectors, single use and parallel cost.
Streams come down to the six ideas below, each listed with the card that covers it.
| The idea | Where |
|---|---|
| Intermediate operations describe; terminal operations run | Stream Laziness: Intermediate and Terminal Operations |
| The terminal operation pulls one element at a time through the whole chain | Stream Laziness Walkthrough: One Element at a Time Through the Chain |
map gives one value per element; flatMap flattens several into one stream | map vs flatMap |
collect and groupingBy decide the shape at the end | Collectors: Ending a Stream in a List, a Set or a Map |
| A stream holds a way of pulling elements, so it cannot be run twice | Why a Stream Cannot Be Used Twice |
| Parallel costs splitting and combining before it saves anything | Parallel Streams: Why parallel() Can Make a Pipeline Slower |
A pipeline is a description of work, pulled by its last line. Nothing happening, a stream that will not run twice, and three hundred elements touched out of a thousand are all that one fact showing through.
← → move through sections and cards