Re: Iterator Class?

From: Will Hartung (willh_at_msoft.com)
Date: 07/28/04


Date: Wed, 28 Jul 2004 12:37:14 -0700


"Richard Chrenko" <richard.chrenko@solarenergy.ch> wrote in message
news:opsbuseko0h18bhh@news.hsr.ch...

> I have done performance testing using both get() and Iterator.next(), and
> there is a significant performace penalty when using get() for long Lists.
> It appears as though get() insists on iterating from the beginning of the
> list to arrive at the desired element. For short Lists, however, the
> overhead of constructing the Iterator object outweighs its benefits.

I'll disagree with this, falling on the "fuzzy" code clarity and consistency
metric side of the fence, and benefits it provides over micromanaging which
iteration method to use.

I use Iterators basically without thinking "gee is this a big list or a
small list", and never worry about the difference. So far in the systems
I've written, the profiler has never complained about iterating over a 10
element list.

The cognitive load that Iterators lift off of the user is very uplifting.

Regards,

Will Hartung
(willh@msoft.com)



Relevant Pages

  • Re: Accessing next/prev element while for looping
    ... > The python way is much more succinct. ... > previous or the next element in the array before continuing iterating. ... > incredibly silly given that python lists under the hood are linked ... the iterator used by the for loop, not the list it is iterating over. ...
    (comp.lang.python)
  • Re: Vector or List
    ... > I'm fairly new to the STL and i was wondering when was the best situations ... to elements other than iterating over them ... For lists, ... I'm Schobi at suespammers dot org ...
    (microsoft.public.vc.stl)
  • Re: Iterator Class?
    ... > there is a significant performace penalty when using getfor long Lists. ... > It appears as though getinsists on iterating from the beginning of the ... > list to arrive at the desired element. ... the profiler has never complained about iterating over a 10 ...
    (comp.lang.java.help)
  • Re: variable declaration
    ... would forbid iterating through lists containing a mix of different types. ... you declare a variant type where the rules are relaxed *for that situation ... Thomas Bartkus ...
    (comp.lang.python)