Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b49nGy7tcEjVUa3WAA
28 lines
742 B
Plaintext
28 lines
742 B
Plaintext
== 1. Nothing runs until a terminal operation ==
|
|
pipeline built, nothing printed above this line
|
|
now call toList():
|
|
peek saw 1
|
|
peek saw 2
|
|
peek saw 3
|
|
|
|
== 2. Elements flow one at a time through the whole pipeline ==
|
|
after filter: 1
|
|
after map : 1
|
|
after filter: 3
|
|
after map : 9
|
|
after filter: 5
|
|
after map : 25
|
|
|
|
== 3. Short-circuiting stops early ==
|
|
anyMatch(n > 10) = true, elements touched = 3 of 6
|
|
|
|
== 4. count() may skip the pipeline entirely ==
|
|
count = 3 (no peek lines: the size was known from the source)
|
|
peek saw 1
|
|
peek saw 2
|
|
peek saw 3
|
|
count after filter = 3 (filter makes the size unknown, so peek runs)
|
|
|
|
== 5. A stream is single use ==
|
|
IllegalStateException: stream has already been operated upon or closed
|