Gatherers -- conditionalWindowFixed?

David Alayachew davidalayachew at gmail.com
Wed Jan 10 06:05:57 UTC 2024


Hello Core Libs Dev Team,

I have been reading through JEP 461 (https://openjdk.org/jeps/461) about
Gatherers, and I'm really excited for what this will enable for us.

By far, the most important functionality that this API facilitates is the
ability to create windows. Anytime I needed a window, I was basically
forced to use a for loop. Now, the 2 most common window cases are being
handed to us for free. It is very much appreciated.

Could we add one more method for a conditionalWindowFixed? We would need to
pass in some Predicate<T>. If the predicate returns true, create a list (if
it does not already exist) then add the element to it. If the predicate
returns false while the list is empty, then just move along to the next.
Else if the predicate returns false while the list is non empty, pass the
list down into the stream. So, you end up with Stream<T> ----->
Stream<List<T>>.

The reason I think this is worth adding is because it facilitates a really
common use case. We may not want all windows to be the same size.

Is this something worth adding to the Gatherers API?

Thank you for your time and help!
David Alayachew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/core-libs-dev/attachments/20240110/48697901/attachment.htm>


More information about the core-libs-dev mailing list