矢量<> VS阵 [英] Vector.<> vs array

查看:161
本文介绍了矢量<> VS阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有哪些优点和使用 Vector的反政府<> 而不是阵列

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

推荐答案

的Adobe文档页面

由于它的限制,因此,一个向量拥有的Array实例元素均为单个类的所有实例两个主要好处:

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:

  • 性能:数组元素访问和迭代的速度更快使用使用数组时,比一个Vector实例时
  • 类型的安全性:在严格模式下,编译器可以识别数据类型错误,如分配不正确的数据类型的值给Vector或从Vector中读取值时使用错误的数据类型。但是请注意, 即使用push()方法或不印字()方法将值添加到载体的情况下,参数的数据类型,不会检查在编译时间,但在运行时进行检查。
  • 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.

这篇关于矢量&lt;&GT; VS阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆