To clarify (since to some it might seem like Alex is all but admitting
that Adobe couldn't code their way out of a wet paper bag),
ArrayCollection.getItemIndex() is horribly inefficient *by design*.
There are always trade-offs when designing data structures, and it's
impossible to make a data structure that's optimally efficient for
everything. Making getItemIndex() efficient would have sabotaged other
performance characteristics of ArrayCollection.
-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: Alex Harui <[EMAIL PROTECTED]>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com <flexcoders@yahoogroups.com>
Subject: RE: [flexcoders] Re: speed of the "for each" looping
Date: Wed, 10 Dec 2008 09:14:38 -0800

Keep in mind that getItemIndex is horribly inefficient.

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Cato Paus
Sent: Wednesday, December 10, 2008 6:50 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: speed of the "for each" looping


 


if you need to get the i you can use the getItemIndex::ArrayCollection

--- In flexcoders@yahoogroups.com, "Amy" <[EMAIL PROTECTED]> wrote:
>
> --- In flexcoders@yahoogroups.com, "Josh McDonald" <dznuts@> wrote:
> >
> > *nods*
> > 
> > I find that it's often much easier to read when you use for..in 
and 
> for
> > each..in rather than regular for. And since you need to have 
a "var 
> current
> > = list[i]" or similar as the first line, If you only need an 
index 
> to
> > display, or it's 1-based as opposed to 0-based, using a "for 
> [each]..in" and
> > having the first inner line be "++idx" will be easier to read 
than 
> a bunch
> > of statements within your loop that look like:
> > 
> > var current = foo[i+1]
> > 
> > or
> > 
> > msg = "you're at item #" + (i + 1)
> 
> The thing is, I nearly always find I need that i for something else 
> other than just iterating, so even when I start out with a for each 
> loop, about 80% of the time I wind up switching back so I have that 
i 
> to get hold of. Since I know that this is quite likely to happen, 
I 
> just "cut to the chase" and use the indexed loop.
> 
> -Amy
>


 


Reply via email to