1. You shouldn't assume that for-in loops iterate in any particular order
because it is subject to change in future versions of the Flash player.

2. To do this efficiently I think you'd need to maintain a secondary array
that keeps track of the populated indices in the primary array:

    populatedIndices = [ 2, 100, 2000 ];

- Gordon

-----Original Message-----
From: Eric Raymond [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 23, 2005 4:59 PM
To: [email protected]
Subject: [flexcoders] Re: internal representation of an array




--- In [email protected], Gordon Smith <[EMAIL PROTECTED]> wrote:
> The Flash player implements both Array and Object as hashtables. In 

Two somewhat related questions:

1) How does the implementation work with "for in" loops?  Is there any
natural order in which the propery names are returned?  Does this vary
from an Array to an Object?

2) Is there an "efficient" way to walk a sparsely populated array in
order?  That is if a[2], a[100] and a[2000] are the only elements of
an array, is there a way to visit the three nodes in order without
testing all the "empty" elements between the sparse nodes.

for (var i:Number=2; i < a.length; i++) {
  if (a[i] != undefined) ...
}

If the array elements were created in order of the increasing index,
would that help?  That is, walking the sparse elements in creation
order would suffice in this case.






 
Yahoo! Groups Links



 





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to