Spliterator is not only about parallelism
Many are still mistaken about the purpose of
It is not only about parallelism.
Spliterator is the core traversing mechanism of Java Streams,
regardless of being processed in parallel or sequentially.
Whenever you build a
Stream from an
Iterator you are wrapping
it around a
Spliterator and incurring in useless indirections.
Remember the answer stated by Bryan Goetz (author of Java streams)
to the question of Miguel Gamboa about the choice between
Stream regarding laziness in a domain model design, namely:
Spliteratorhas fundamentally lower per-element access costs than _Iterator, even sequentially._”
- ” The Iterator protocol is fundamentally less efficient.”
Spliteratorfurther offers a “fast-path” iteration”