zoukankan      html  css  js  c++  java
  • Array的使用技巧

    Array的使用技巧

     

    There are many instances when you might want to loop through all the elements of an array. For example, by looping through an array containing references to sprites, you can perform a particular action on each of the sprites:

    for (var i:int = 0; i < sprites.length; i++){  // Move each sprite one pixel to the right.  sprites[i].x++;}

    You can store the array's length in a variable rather than computing it during each loop iteration. For example:

    var length:int = sprites.length;for (var i:int = 0; i < length; i++){  // Move each sprite one pixel to the right.  sprites[i].x++;}

    The effect is that there is a very marginal performance improvement because Flash doesn't have to calculate the length during each iteration. However, it assumes that you are not adding or removing elements during the loop. Adding or removing elements changes the length property. In such a case, it is better to calculate the length of the array with each iteration.

     

     public native function splice(startIndex:int, deleteCount:uint, ... values):Array;

  • 相关阅读:
    git reset 用法
    print、println、printf的区别
    GoLang(2)
    GoLang
    OpenCV 图像叠加or图像混合加权实现
    openpyxl
    EJB 的理解
    inotify-tool实时监控服务器文件状态变化 学习总结
    使用docker 安装maven私服 nexus
    dockerfile 学习总结
  • 原文地址:https://www.cnblogs.com/jiahuafu/p/1638738.html
Copyright © 2011-2022 走看看