For...each...in loop.  Can I make assumptions about the order?

I've always assumed that I can't make any assumptions about the order in which elements are indexed by a for...each...in loop.  Not even for a conventional indexed array.  (Emphasis!: I'm not talking about associative arrays here, I'm talking about normal indexed arrays.  Dense, no gaps.).
for each (var element:ElementClass in myArray) {}
May not traverse the array from first to last.  I've never assumed that it's guaranteed anyway.  Neither does the ECMA standard.  I assume the compiler/runtime is at liberty to index the array in any order, which may even be different each time. 
Whereas... for (var i:int=0;i<myArray.length;i++) {......var element:ElementClass=myArray[i]....}
....Is guaranteed to traverse the array from first to last.  So I always use this looping statement if the ordering is important.
MY QUESTION IS.... In ActionScript 3, Can I just assume that the for..each..in will always traverse a dense indexed array from first to last?
Actually, my specific case at the moment is where another programmer is passing me an array,assembled within a for...each..in loop.   But I need to assume the order of that array.  If this is always going to work in ActionScript3, then no problem.  Although I'll continue to worry about the ECMA standard for my own code, and wont make assumptions about ordering - but I won't force my anal-retentive programming style on the other guy.

I did a test on it
case1:
var arr:Array = new Array();
arr[0] = 'a';
arr[1] = 'b';
arr[2] = 'c';
arr[3] = 'd';
for each(var arrEle:string in arr)
     trace(arrEle);
always output a,b,c,d
case2:
var arr:Array = new Array();
arr[6] = 'd';
arr[0] = 'a';
arr[1] = 'b';
arr[3] = 'c';
for each(var arrEle:string in arr)
     trace(arrEle);
always output a,b,d,c
so I assume array is created in this way: alloc a memory block for array first, when attaching new element(numeric indexd by i) to array, check if i >= length, put new element in the end of array, else put element at i; so in case 2, array is alloced in this way
array:{'d'} //6>0
array:{'a', 'd'} //0<1
array:{'a', 'b', 'd'} //1<2
array:{'a', 'b', 'd', 'c'} //3>=3
disclaimer: totally assumption!!!

Similar Messages

  • HT1495 Multiple ipads for classroom use how can I make them have the same apps?

    How do I sync multiple ipads for classroom use

    There is no bookmarks tab, expect you are referring to the bookmarks menu on the menu bar ("File, Edit, View, History, Bookmarks, Tools, Help") on your XP system.
    Once your restore your menus on you Window 7 system, you can get rid of the bookmarks button. After going through the 10 steps below your toolbars on your Windows 7 system will be more usable again and like your XP system, none of which has anything to do with Sync.
    You can make '''Firefox 6.0.1''' look like Firefox 3.6.*, see numbered '''items 1-10''' in the following topic [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 thru 8.0, look like 3.6)]. ''Whether or not you make changes, you should be aware of what has changed and what you have to do to use changed or missing features.''
    * http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface
    the first 9 steps above are basic toolbar customization the following link is in step #1 above. (See before/after picture (.png) in the footnote)
    *How do I customize the toolbars? | How to | Firefox Help
    *:https://support.mozilla.com/en-US/kb/how-do-i-customize-toolbars
    <br><small>Please mark "Solved" one answer that will best help others with a similar problem -- hope this was it.</small>
    There is a lot more beyond those first 10 steps listed, if you want to make Firefox more functional.
    Before and after customizations, the following also includes [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4styles styling changes] besides rearranging toolbars and toolbar items.
    * http://dmcritchie.mvps.org/icons/fx4toolbars.png
    *:Bookmarks toolbar -- [http://userstyles.org/styles/46947 Bookmarks Toolbar Fx4 Blue/Folders, Red/Bookmarks]
    *:Tab borders -- [http://userstyles.org/styles/24728 Tab Color Underscoring active/read/unread (Fx3.6)] red=active tab, blue=read, green=unread, magenta(not shown)=loading

  • IPAD IOS5 apps badge font too small to easily read (for me). How can I make it larger?

    My iPad IOS5 apps badge font too small to easily read (for me). How can I make it larger? It was larger and much easier to read on IOS4.

    press [ctrl] + [+]
    More details: [[page zoom]].

  • B1if - #sender system in for each processing loop

    Hi all,
    I am creating a scenario where I use the for each processing loop.
    Everything works fine but when I want to use the #Sender system in various steps (call B1 atom eg), I get an error saying the #Sender system is empty.
    Do I need to do something to get it populated inside the for each loop?
    Kind regards,
    Joeri

    Hi Joeri,
    I have done a test and I have the same problem you are having the system is empty when I use the #Sender System in a B1 call inside a for each. If I use a fix system id then it works fine.
    <?xml version="1.0" encoding="utf-8" ?>
    <Msg xmlns="urn:com.sap.b1i.vplatform:entity">
      <Body>
        <Payload Role="C" id="atom3" system="empty">
          <B1CallResult status="failure" b1login="Technical User" method="Synchronous Retrieval" objectid="4" payload="" keyname="ItemCode" keyvalue="A00001" />
        </Payload>
      </Body>
    </Msg>
    Please open a message for support asking for it and share the information with us.
    Hope it helps
    Trinidad.
    Edited by: Maria Trinidad MARTINEZ GEA on Jan 6, 2012 11:00 AM
    My previous answer was not related to your question...

  • Can i make all inboxes the default that opens each time i open mail

    Can I make "all inboxes" the default that opens each time I check mail?

    Agreed! I think it's absurdly rediculous that it can't be set to open by default on the "All Inboxes" screen! This SHOULD be an option! It's a huge pain to be forced to exit a "single accounts inbox" then go back into the "all inboxes" screen. It's redundant. LOL. I was really hoping that they would add this option in ios 7...

  • How can I make "No Proxy" the default for accessing the internet?

    How can I make "No Proxy" the default for accessing the internet?

    *Tools > Options > Advanced > Network : Connection > Settings
    If you do not need to use a proxy to connect to internet then try to select "No Proxy" if "Use the system proxy settings" or one of the others do not work properly.
    See "Firefox connection settings":
    *https://support.mozilla.org/kb/Firefox+cannot+load+websites+but+other+programs+can

  • HT4528 icloud says maximum number of free accounts for this iphone  how can i make it work?

    icloud says maximum number of free accounts for this iphone  how can i make it work?

    You have created too many accounts. There's no way to get around this.

  • How can I make GRID view the default view? The icons for view that used to be located in the upper right top of the page near the 'search library' are gone.

    How can I make GRID view the default view? The icons for view that used to be located in the upper right top of the page near the 'search library' are gone.

    99jon wrote:
    Perhaps it’s a design feature to speed up the Organizer launch.
    I am sure it is.
    - The normal use of the Organizer is not the folder view, it's the thumbnail view with an organization based on categories and folder. That way you should forget completely where your pictures are stored. Anyway, the folder view in the Explorer is not a map of the location of the different bits of your file, it's only a logical representation. That's easy to see when you are doing a defragmentation.
    - The folder view is useful even for those using normally the thumbnail view, but that is only for rare cases when you must change the folder organization, for instance moving files to another drive. The folder view is here to prevent you from changing things from the explorer and outside of the Organizer.
    - The new folder list view, which you find 'funny' is there to help better organizing using tags. Its huge advantage is that such a view is created extremely quickly by extracting the last subfolder in the media table : it's the way the database sees the folders, based on its own content,  totally ignoring the complex folder organization of your disk with media files or any unrelated other kind of data. You should use it in many cases, the main purpose being assigning tags when you have assigned descriptive folder names. I had suggested such a solution to prevent the long standing bugs in the folder view of previous versions.
    So yes, the purpose is:
    - to speed up switching modes
    - to help folder organization fans to migrate to tags organization
    - to hopefully get rid of the old folder organization bugs

  • I'm using iphone 4s with ios6, but why can't make facetime over the cellular networks?thanx for the answer

    i'm using iphone 4s with ios6, but why can't make facetime over the cellular networks?thanx for the answer

    Depends on your carrier and data plan.
    With ATT in the US for example, you can FaceTime via ATT's cellular network if you have a shared data plan only.

  • I have a Mac desktop and also a MacBook Air.  Do I have to buy the OS X Lion for each device or can I buy one for both devices?

    I have a Mac desktop & also a MacBook Air.  Do I have to buy the OS X Lion for each device or can I buy one for both devices?

    jamesfromdundas wrote:
    you get three copies for thirty bucks press puchased items from app store on your other machine.  follow orders.
    That is incorrect james, you can install it on ALL the computers you own, no limit.

  • After updating to mavericks on my MacBook, the screen keeps saying "setting up your mac." It has been like this for hours! How can I make it go faster?

    After updating to mavericks on my MacBook, the screen keeps saying "setting up your mac." It has been like this for hours! How can I make it go faster? It's has been like this for 4 hrs.

    I don't think your mac is setting up. It's stuck.
    I would:
    hold the power button until it shuts down
    unplug all peripherals
    do a safe boot (restart and hold down the shift key until you see the apple logo).
    If it starts up in a safe boot, then you can try restarting with a normal boot.
    If it does not start with a normal boot, then you probably have some incompatible third party software. Likely culprits are:
    MacKeeper
    CleanMyMac
    third-party antivirus software
    any other "cleaning" or "optimizing" or similar third party "utilities".
    A good place to start would be to uninstall any of those (while in safe mode) and then restart.

  • Looking for a drum loop app that will run in the background. What are you using?

    Looking for a drum loop app that will run in the background. Suggestions? What are you using? I tried Loopseque and I like it, but I can't make it run once I switch apps. Help please.

        That's definitely strange, kzmidge. I want a working phone in your hands though. I noticed you mentioned you received the suggestion to complete a reset. Did you already do that? Is it working again? Are you receiving an error message?
    If you hesitated a little longer to complete the reset, you can try to place your phone into Safe Mode http://vz.to/rxg0ii and see if you can access mobile sites from your browser. This mode will stop 3rd party applications from running, so you won't be able to use the apps you mentioned but we may be able to narrow down the trouble in Safe Mode. If the mobile sites work, that means the trouble may be in a recently downloaded application and you may be able to avoid the reset my uninstalling some of your more recently installed applications. If it's still giving you trouble, the reset http://vz.to/18wzOCi is the next best step.
    JenniferH_VZW
    Follow us on Twitter www.twitter.com/vzwsupport

  • I have changed the email signature on my iPhone, when composing a new email the signature is there, however when I am replying to an email it is not, how can I make sure that the signature is at the end of every email I send?

    I have changed the email signature on my iPhone, when composing a new email the signature is there, however when I am replying to an email it is not, how can I make sure that the signature is at the end of every email I send?

    Yes I know what you mean about it cluttering the thread and for personal emails it is better without the signature. However this relates to sending business emails from an iPhone so I need the signature present on every email.
    I can't find anything in Settings so I was hoping someone may have some knowledge/information/experience regarding this problem.

  • In iOS 7 you can still make calls from the locked screen. Just swipe the missed call numbers to the right. Is this a bug?

    In iOS 7 you can still make calls from the locked screen. Just swipe the missed call numbers to the right. Is this a bug?

    How is it a security breach? You're free to turn off lock screen notifications for the phone app so that no one can do that.... even if they can, they can only call the number that called you... nothing else. (well, except for 900 or whatever the emergency services number is where you are, but that's required by law).

  • Can someone make iBooks have the Option to view 2 pages in landscape mode so it can use up all the pixel real estate?

    Can someone make iBooks have the Option to view 2 pages in landscape mode so it can use up all the pixel real estate?
    Apple usually does this for OSX and its great when compared to windows where it doesnt use up all the real estate for viewing applications like websites and pdf files but when it comes to iBooks, it feels like there is no apple touch to it and is limited.
    If steve jobs were still alive, i bet there wouldnt be this problem >.>
    Please consider this as a real problem for people out there who would like to see 2 pages in landscape mode with pdf files and not just epub files.
    Thanks!

    Penguin, do you always insult people on here or was I just a special case?
    If you read the statement carefully, which you obviously did not! I was speculating, and I did not say anything for certain about knowing or not knowing ...
    I'm happy for the reply to the post and helpful link you posted to where I can leave some feedback for my post on an Apple monitored site but i rather you not reply if your gonna leave a snyde remark with every helpful comment.
    Don't do it again. and Thanks for the help.

Maybe you are looking for