And this may also be better named as a split method instead of the long conditionalWindowFixed.
On Wed, Jan 10, 2024 at 1:17 AM David Alayachew <davidalayac...@gmail.com> wrote: > Oh, I made a mistake. Let me try it again. > > If the predicate is true, add the element to the current list (create list > prior if needed). Else if the predicate is false, send the list down to the > stream, then add the element to a new list (the new current list, if you > will). > > > On Wed, Jan 10, 2024 at 1:05 AM David Alayachew <davidalayac...@gmail.com> > wrote: > >> 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 >> >