About count()
Jose
jgetino at telefonica.net
Mon Aug 27 14:16:03 PDT 2012
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