overloads for java.util.RandomAccess

Remi Forax forax at univ-mlv.fr
Wed Oct 31 03:42:49 PDT 2012


On 10/31/2012 08:54 AM, Gernot Neppert wrote:
> (Note: The current version has a performance issue, as the erased argument
> type is not java.util.List, but rather java.util.RandomAccess, and there's
> an invisible checked cast involved in every single invocation of any of
> List's methods. Probably not what the author intended)

True,
the signature should be
   public static <T, L extends List<T> & RandomAccess> Stream<T> 
stream(L source)

and I also agree with you that java.util.RandomAccess should not be used 
as a type in a signature but to select the stream implementation at runtime.

regards,
Rémi



More information about the lambda-dev mailing list