<div dir="auto"><p dir="ltr">Hi. There has been a proposal from me (that Chen mentioned), approximately half a year ago. At the time I have insisted on creating stream sub interface, and even got a working prototype for sequential streams, but there have been such a huge complexity blowup in parallisation that I have just decided to drop it. Gatherers can be used pretty easily for this task, but using ofSequential, sacrificing parallelism. So basically, parallelism is a pain point here (or performance). I am not saying that it is impossible to console enumeration and prallelisation, but it will require huge efforts and invasive changes in current *Pipeline implementations, or enormous amounts of code duplication</p></div>
<br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Dec 5, 2024, 18:48 Henrik Wall <<a href="mailto:xehpuk.dev@gmail.com" target="_blank" rel="noreferrer">xehpuk.dev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hey folks,<br>
<br>
Not having access to the index of an element of a stream is often a<br>
reason to fall back to a traditional loop, at least for me. I'd love<br>
to have `Gatherers.indexed()` that looks something like this:<br>
<br>
public static <TR> Gatherer<TR, ?, Map.Entry<Integer, TR>> indexed() {<br>
return Gatherer.ofSequential(<br>
() -> new int[1],<br>
Gatherer.Integrator.ofGreedy((state, element, downstream) -><br>
downstream.push(Map.entry(state[0]++, element)))<br>
);<br>
}<br>
<br>
(Potentially with a custom pair class to avoid auto-boxing.)<br>
<br>
In other popular languages like Python or Rust, this is also called `enumerate`.<br>
<br>
Any chance to get that in a future release?<br>
<br>
Regards,<br>
Henrik<br>
</blockquote></div>