This page is no longer maintained — Please continue to the home page at

Re: Re: Why Iterators ever?

No replies
Joined: 2011-09-25,
User offline. Last seen 1 year 2 weeks ago.

Hi Roland,

> Just today i had a use-case: I want to traverse a data structure driven by a “list” of items. Passing around iterators obviates the need for creating new (smaller) collections at each step;
> since the code in question is kind of a hot path, I would rather not have that many allocations happening on it, so one Iterator seems like a decent compromise between performance and
> readability (the alternative being to pass around an IndexedSeq and an index).

So, if I understand you correctly, you're telling me that you derived
your own iterator class from the Iterator trait and enjoyed the wealth
in its interface?



Seyed H. HAERI (Hossein)

Research Assistant
Institute for Software Systems (STS)
Technical University of Hamburg (TUHH)
Hamburg, Germany

ACCU - Professionalism in programming -

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland