Search code examples
arraysactionscriptvectorflashplayer-10

Vector.<> vs array


What are the pros and contras of using a Vector.<> instead of array?


Solution

  • From the adobe documentation page:

    As a result of its restrictions, a Vector has two primary benefits over an Array instance whose elements are all instances of a single class:

    • Performance: array element access and iteration are much faster when using a Vector instance than when using an Array.
    • Type safety: in strict mode the compiler can identify data type errors such as assigning a value of the incorrect data type to a Vector or expecting the wrong data type when reading a value from a Vector. Note, however, that when using the push() method or unshift() method to add values to a Vector, the arguments' data types are not checked at compile time but are checked at run time.