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
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
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>
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
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
ods on the
>>>>>>>> list interface streamWithIndex() and parallelStreamWithIndex() that
>>>>>>>> would
>>>>>>>> return a Stream>, as opposed to just Stream.
>>>>>>>>
>>>>>>&
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
("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 :(
>>>>>
>>>>>
; if (predicate.test(element)) {
>> return downstream.push(index);
>> }
>> return true;
>> }));
>> }
>>
>> and use it like this:
>> list.stream().gather(findIndex(s ->
>> s.contains("o"))).f
> 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
>
{
>>> return downstream.push(index);
>>> }
>>> return true;
>>> }));
>>> }
>>>
>>> and use it like this:
>>> list.stream().gather(findIndex(s ->
>>> s.contains("o"))).findFirst(
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-
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
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-
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
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
16 matches
Mail list logo