Adobe officially does not have the term "generic array", which is my own term for vectors (a bit of a title party), but vector is actually somewhat similar to a generic array in C #.
Yang over the original banyan tree
Source: http://yjmyzz.cnblogs.com
We know that array arrays in ActionScript3.0 can hold multiple types, even in the same array of arrays, and can be stored in string,object,number ..., but in fact we are actually developing, Typically, the types of elements stored in an array are consistent, and to improve efficiency in this case, AS3.0 adds a new vector class.
It enforces that each element in the array must be of the same type, eliminating the "boxing", "unpacking" operations, and improving performance.
The following section of the test code shows the performance differences between vectors and array:
1 varcount:uint=50000;2 varv:vector.<string>=NewVector.<string> (count);//declaring methods for vector of generic arrays3 varastr:array=NewArray (count);4 varAobj:array =NewArray (count);5 vari:uint=0,j:uint=100;6 vart:string="";7 8 //Initialize9 for(i=0; i<count-1; i++) {Tenv[i]=math.random (). toString (); Oneastr[i]=V[i]; AAobj[i] = {"a": V[i]}; - } - the //Start Test--vector - varStarttime=Gettimer (); - varElapsed:uint=0; - + while(j--) { - for(i=0; i<count-1; i++) { +t=typeofV[i]; A } at } -Elapsed=gettimer ()-StartTime; - Trace (t); -Trace"vector<string> Time:", elapsed,"\ n"); - - //start Test--array (String) inj=100; -Starttime=Gettimer (); to while(j--) { + for(i=0; i<count-1; i++) { -t=typeofAstr[i]; the } * } $Elapsed=gettimer ()-StartTime;Panax Notoginseng Trace (t); -Trace"Array (String) Time-consuming:", elapsed,"\ n"); the + //start Test--array (Object) Aj=100; theStarttime=Gettimer (); + while(j--) { - for(i=0; i<count-1; i++) { $t=typeofAobj[i]; $ } - } -Elapsed=gettimer ()-StartTime; the Trace (t); -Trace"Array (String) Time-consuming:", elapsed,"\ n");
View Code
Vector of generic arrays in ActionScript3.0 (AS3)