About count()

Brian Goetz brian.goetz at oracle.com
Mon Aug 27 14:37:08 PDT 2012


As mentioned earlier, we're migrating away from putting extensions on 
Iterable, in part for reasons like this.



On 8/27/2012 5:16 PM, Jose wrote:
> I don't know if this makes any sense:
>
>
>
> To know the number of its elements an iterable has the count() method. If we
> are lucky enough that the iterable is a collection, we can get the result
> without looping. However it seems to me that this fast procedure is only
> available at the beginning of the pipeline. After a filter, map o whatever,
> to provide such an info the iterable has to transverse all its elements.
>
>
>
> So I wonder if the Iterables/Iterators used by the pipeline methods could be
> made to track the number of its elements in a auxiliary field, that could be
> accessed by count(). as an additional option before proceed to iterate. Then
> you could keep the count() calls from the logger uncommented,  without risk
> of delay the process. I like very much the pipeline syntax, but debugging is
> becoming a nightmare.
>
>
>
> I also would like to know if a count() would force evaluation of the lazy
> operations.
>
>
>
> Thanks
>
>
>
>
>
>
>
>


More information about the lambda-dev mailing list