A
Streamis a monad that is lazy, in which it could have a infinite list of elements.
A stream is useful as it can be used to truncate repeated similar computations on a list of elements.
Stateful and Bounded Operations
Stateful operations are operations that need to keep track of states to operate. Bounded operations are operations that should only be called on finite streams.
sorted,distinct
stream methods
Factory
iterateTakes in a seed, and aSupplierthat repetitively runs on the seed to get the next element.generateTakes in aSupplierthat generates the next element.
Truncation
limittakes in an integernand returns a stream of the firstnelements.takeWhiletakes in a predicate and returns a stream containing elements of a stream (might not actually return a finite stream if predicate is always false.)
Reduction
reduceIt applies a function repeatedly on the elements of the stream, reducing it to a singular value.
Element Matching
noneMatch,allMatch,anyMatch