Streams arrays and getFirst()

Brian Goetz brian.goetz at oracle.com
Mon Aug 13 07:23:14 PDT 2012


Optimizations like this would happen later in the process, and would be 
prioritized by performance data.  (But I suspect this won't be very high 
on the list of such things.)

On 8/13/2012 7:18 AM, Jose wrote:
>
> To use arrays as inputs for lambda pipelines I'm currentely using:
>
>                   Arrays.asList(myArray).filter(...).map(...)
>
> I'm also testing to refractor some methods in my code
>
> T  foo(List list){}                  to     T foo(Iterable iter)
>
> If the foo() body needs the first element of the iterable,  I can provide it
> with the extension method:
>
>
>                                                            Iterable.
> getFirst()
>
> However I thik that this method could do better in the array case, because
> now it is not checking if the passed argument is a List.
>
> For example, another method in the class
>
>                                                          Iterable.count()
>
> already check for the argument being a Collection and then returns its size,
> no need to compute it.
>
> Would you mind to include the List check in getFirst()?
>
>


More information about the lambda-dev mailing list