You bet, Vector implements Iterable<Vector.Element>!

In the case of SparseVector it only hits the nonzero elements.

I wonder if we can tighten up the contract of Vector in this respect:
- can it really not guarantee in-order iteration? this seems intuitive
and maybe useful
- should state it may not (will not?) hit elements that are zero?

On Tue, Jun 23, 2009 at 5:00 PM, Ted Dunning<ted.dunn...@gmail.com> wrote:
> Do we have a good way to iterate over non-zero elements?
>
> On Tue, Jun 23, 2009 at 12:36 PM, Grant Ingersoll <gsing...@apache.org>wrote:
>
>> I'm doing some more profiling and it seems like all over the place we are
>> looping from i = 0; i < size() and calling getQuick.  This is then, for
>> SparseVector, dominated by the find lookup, which is taking up a lot of
>> time.
>>
>> So, it's not that find() is slow, but the fact that we are needlessly
>> calling getQuick() for loops.
>>
>> Just an FYI as we go forward not to do that.
>>
>>
>

Reply via email to