Migrating methods in Collections
Doug Lea
dl at cs.oswego.edu
Thu Dec 24 18:36:15 UTC 2015
On 12/24/2015 11:01 AM, Brian Goetz wrote:
> I still think the logical signatures here would be:
> E[] toArray()
> <U super E> toArray(IntFunction<U[]> generator)
My thought was: Let them eat streams!
Which already supports:
Object[] toArray();
<A> A[] toArray(IntFunction<A[]> generator);
On the other hand, IntStream adds: int[] toArray();
And similarly for LongStream, DoubleStream, but nothing that
accommodates arbitrary Value-Stream, so the issue might need
to be addressed somewhere somehow.
>
>> boolean removeAll(AnyCollection<? extends E> c); // not
>> Collection<?>
>> boolean retainAll(AnyCollection<? extends E> c); // not
>> Collection<?>
>
> Arguably better handled by remove(Predicate)
Sure. I agree there's no good rationale for these in
Collection super-interface. (On the off chance that we
actually split them...)
>
>> long findFirst(E e);
>> long findLast(E e);
>
> Arguably better as findXxx(Predicate)
I agree about adding predicate versions.
But people will complain about requiring a lambda in plain version
that otherwise ought to be simple enough to compile into
optimal machine instruction loop for ArrayLists
More information about the valhalla-spec-experts
mailing list