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
Viktor Klang
Software Architect, 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 findIndex and findLastIndex m
Regarding what Holo said, I think enumerated() would be a more suitable
name.
I have few ideas about implementation of such things, like separate
EnumeratedStream interface, which extends stream and provides methods like
forEach(BiConsumer), etc. This would eliminate unnecessary
object instantiati
Hello,
I want to challenge the idea that every stream may be indexed for 3 reasons:
Any sensible type to use for an index (int/long) will be bounded, but
streams need not, e.g.
new Random().ints().withIndex().forEach(v -> ...);
May result (after a very long time) non sensical values. Using bi
Hi Rotan',
Interface methods are both exposed to callers and to implementations. Is
there any scenario where the implementation can be more efficient than the
stream/gatherer scanning approach?
indexOf or lastIndexOf may be faster if a list has some tricks like a
hashmap to quickly look up the ind
Turned out this whole time I was only replying to David. I have to thank
him for his patience explaining me how this whole mailing thing work.
To summarize what has been missed out, besides what have you seen in
quotes. I have pointed out that, while flexibility and simplicity is
important, the ma
> That was what i referred to as "Map-solvable" problems,
> but if this way of doing it is a thing, then I agree with
> the point.
Doing it the Map way would not only be slower, but it would force you to
include more concepts than you need. Your identifier is your index.
Lists/arrays have index. B
> I think that, while finding the index of a matching
> element is not a very common task, especially among
> commercial developers, when discussing indexed streams,
> this would be the most common use case. To be honest, I
> don't even see any other use cases right now, besides
> maybe some proces
on to use .withIndex().
list
.stream()
.withIndex()
.filter(WithIndex.filter(predicate))
.mapToIndex()
.findFirst()
.orElse(-1)
On Fri, Apr 19, 2024 at 5:47 PM wrote:
>
>
> --
>
> *From: *"David Alayachew"
> *To: *"Rem
> 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
>
It is not the goal of Java to be verbose, but it is also not the goal of
Java to be concise either. It is the goal of Java to be clear, correct, and
readable, in order to maximize maintainability, correctness, and
flexibility. When you focus on accomplishing that goal first, you will find
that conc
Thanks for the advice. Indeed, it was a mistake to implement this before
discussing it in mail. This is my first open-source experience, so i guess
this will be a valuable experience for my future contributions
сб, 20 апр. 2024 г. в 00:12, David Alayachew :
> Hello
>
> Thanks for sending this ema
Hello
Thanks for sending this email. Your idea makes a lot of sense, but I feel
that it only serves a very specific use case. That does not make it bad,
but it does make it narrow.
I already suggested my idea in my email to Rémi, where the index is just
another field in the data type being stream
No Rémi, I don't think your idea is the right approach. You are working on
the wrong level of abstraction.
Many 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 user above request
Hello,
for me, it seems what you want is Collector on Stream which is able to
short-circuit,
so you can write
list.stream().collect(Collectors.findFirst(s -> s.contains("o")))
and in reverse
list.reversed().stream().collect(Collectors.findFirst(s -> s.contains("o")))
Using a Stream here is
15 matches
Mail list logo