This lstream library provides both
- an API for sequential only stream
- an implementation based on iterators
Stream API is a very powerful, functional way of managing collections of objects. Its parallelisation usage offers a
great way to iterate with high performance.
However, parallelisation is used in very few cases an everyday project, but the parallel API still exists : it is
inconvenient to be forced to write a merge function when reducing a sequential stream.
Iterator is a very understandable way of iterating over a collection.
However, it lacks some functional API to get more modern.
This library defines the same API as the Stream one but without the parallelisation.
It also offers an implementation with iterators.
Let numbers
be a list of integers. We want to keep only even ones, sort, and create a new immutable list.
LStream.from(numbers).filter(n -> n%2 == 0).sorted().toList();