Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-23 Thread ІП-24 Олександр Ротань
itect, Java Platform Group > Oracle > > ------ > *From:* core-libs-dev on behalf of Remi > Forax > *Sent:* Friday, 19 April 2024 19:47 > *To:* ІП-24 Олександр Ротань > *Cc:* core-libs-dev > *Subject:* Re: Addition of Predicate-based findInde

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-23 Thread Viktor Klang
i From: "ІП-24 Олександр Ротань" To: "core-libs-dev" Sent: Friday, April 19, 2024 5:59:39 PM Subject: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List Subject Addition of Predicate-based findIndex and findLastInde

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-20 Thread ІП-24 Олександр Ротань
done in a way that services a much larger >>>>>>>>> group of >>>>>>>>> users and use cases. I think my idea does that. >>>>>>>>> >>>>>>>>> On Fri, Apr 19, 2024 at 5:14 PM ІП-24 Олександр Ротань < >>>>>>>>> rotan.olexa...@gmail.com>

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-20 Thread Holo The Sage Wolf
st().orElse(-1) is >>>>>>>>> still >>>>>>>>> long, thats why i think there is room for both in Java. >>>>>>>>> >>>>>>>>> Also maybe instead of returning traditional -1 it would be more

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-20 Thread -
any users ask requests like this all the time, and what you are >>>>>>>>> suggesting would be even more error-prone than the equivalent for >>>>>>>>> loop or the >>>>>>>>> IntStream suggestion that the

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread ІП-24 Олександр Ротань
ods on the >>>>>>>> list interface streamWithIndex() and parallelStreamWithIndex() that >>>>>>>> would >>>>>>>> return a Stream>, as opposed to just Stream. >>>>>>>> >>>>>>&

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
correct answer obvious. If >>>>>>> I need to do something with an index, stream with the index. >>>>>>> >>>>>>> On top of that, it significantly enhances readability by making it >>>>>>> clear to the reader that, wh

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
("o"))) >>>>> >>>>> Using a Stream here is more general and will work with other >>>>> collections like a LinkedHashSet for example. >>>>> Sadly, there is no way to define a short-circuiting collector :( >>>>> >>>>>

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
; if (predicate.test(element)) { >> return downstream.push(index); >> } >> return true; >> })); >> } >> >> and use it like this: >> list.stream().gather(findIndex(s -> >> s.contains("o"))).f

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread forax
> From: "David Alayachew" > To: "Remi Forax" > Cc: "ІП-24 Олександр Ротань" , "core-libs-dev" > > Sent: Friday, April 19, 2024 11:02:12 PM > Subject: Re: Addition of Predicate-based findIndex and findLastIndex methods > to >

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
{ >>> return downstream.push(index); >>> } >>> return true; >>> })); >>> } >>> >>> and use it like this: >>> list.stream().gather(findIndex(s -> >>> s.contains("o"))).findFirst(

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread ІП-24 Олександр Ротань
m().gather(findIndex(s -> >>> s.contains("o"))).findFirst().orElse(-1); >>> >>> But it's more verbose. >>> >>> I wonder if at the same time that the Gatherer API is introduced, the >>> Collector API should be enhanced to support short-

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
is: >> list.stream().gather(findIndex(s -> >> s.contains("o"))).findFirst().orElse(-1); >> >> But it's more verbose. >> >> I wonder if at the same time that the Gatherer API is introduced, the >> Collector API should be enhanced to support short-c

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread David Alayachew
I wonder if at the same time that the Gatherer API is introduced, the > Collector API should be enhanced to support short-circuiting collectors ? > > regards, > Rémi > > > ---------- > > *From: *"ІП-24 Олександр Ротань" > *To: *"core-libs-

Re: Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread Remi Forax
ibs-dev" > Sent: Friday, April 19, 2024 5:59:39 PM > Subject: Addition of Predicate-based findIndex and findLastIndex methods to > java.util.List > Subject > Addition of Predicate-based findIndex and findLastIndex methods to > java.util.List > Motivation > The motiv

Addition of Predicate-based findIndex and findLastIndex methods to java.util.List

2024-04-19 Thread ІП-24 Олександр Ротань
Subject Addition of Predicate-based findIndex and findLastIndex methods to java.util.List Motivation The motivation behind this proposal is to enhance the functionality of the List interface by providing a more flexible way to find the index of an element. Currently, the indexOf and lastIndexOf