阵列AS3矢量

编程入门 行业动态 更新时间:2024-10-18 14:15:12
本文介绍了阵列AS3矢量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

是否有数组类型的Vector中存储阵列的任何性能优势?

Is there any performance benefit in storing Arrays in a Vector of type Array?

例如选择1

private var _arrays:Vector.<Array> = new Vector.<Array>(2); _arrays[0] = new Array(10); _arrays[1] = new Array(10);

选项2

private var _arrays:Array = new Array(2); _arrays[0] = new Array(10); _arrays[1] = new Array(10);

我也可以有一个或多种载体?

Also can I have a Vector or Vectors?

private var _vectors:Vector.<Vector> = new Vector.<Vector>(2); _vectors[0] = new Vector.<String>(10); _vectors[1] = new Vector.<String>(10);

谢谢

标记

推荐答案

修改

我原来的答案是错的除了最后一部分,我要为此向您道歉。我知道一个事实,矢量有正好四条实施引擎盖下。 (你可以找到反编译的FP 10的playerglobal.swc源后由罗伯特·彭纳这里)三个是对于数字类型(INT,UINT和号码)。一个是对象类型。这最后一个作为一个包罗万象的,并采取了从Object派生的所有类。这就是为什么我认为矢量&lt;对象&gt; 仍较阵列快,靠的关于矢量和阵列可从Adobe 的信息。

My original answer was wrong except for the very last part, and I have to apologize for that. I knew for a fact that Vector has exactly four implementations "under the hood". (You can find decompiled sources from FP 10 playerglobal.swc in a post by Robert Penner here) Three of those are for number types (int, uint and Number). One is for Object types. This last one serves as a catch-all and takes in all classes derived from Object. This is why I assumed that Vector.<Object> was still faster than Array, relying on the information regarding vectors and arrays available from Adobe.

不过,似乎这个信息是错误的,或者至少是它忽略了一些重要的部分:

However, it seems that this information is wrong, or at least it leaves out some important parts:

  • 在矢量&lt;。AnyClassDerivedFromObject&GT; 允许进行严格分型,这种类型的信息,只能判断在编译时间(让你得到更多的类型安全),但不能在运行时 - 从而实质上严格的键入的对象矢量的好处并不适用于性能。请参见这篇博客获取更多的信息。

  • While Vector.<AnyClassDerivedFromObject> allows for strict typing, this type information is only evaluated at compilation time (so you get more type safety), but not at runtime - thus essentially the benefits of strict typing object vectors do not apply to performance. See this blog post for more info.

    因此​​,向量,比快数组是那些对数字类型(!),唯一的实现

    Consequently, the only implementations of Vector that are faster than Array are the ones for number types (!).

    事实上,我已经做了这方面的一些广泛的测试,并得出结论,虽然矢量&lt; INT&GT; 比阵列快达60%整数的,矢量&lt所有的衍生物;对象&gt; 不仅是相等的速度(即矢量&lt;对象&gt; 执行相同的矢量&lt;串&GT; ,他们也有20%左右的慢比阵列我有双和三查这个,所以我相信结果是相当准确的。

    In fact, I have done some extensive testing on this, and have come to the conclusion that while Vector.<int>is up to 60% faster than Array of ints, all the derivates of Vector.<Object> are not only equal in speed (i.e. Vector.<Object> performs the same as Vector.<String>, they also are about 20% slower than Array. I've double- and triple-checked this, so I believe the results to be fairly accurate.

    它仍然是真实的,数量型载体速度更快,所以你应该使用那些在阵列的性能优势。但是:

    It still is true that the number type vectors are faster, so you should use those for performance benefits over Array. But:

    END修改

    只有当你要使用的sort(), sortOn()按或其它任何方便的排序阵列的功能,你可能还是另作决定,因为这些都是原生的功能,正因为如此的真正的快。实现对矢量自己的排序方法可能会自己的速度不匹配。

    Only if you're going to use sort(), sortOn() or any other of the convenient sorting functions of Array, you might still decide otherwise, because these are native functions, and as such really fast. Implementing your own sorting methods on a Vector will probably not match their speed.

  • 更多推荐

    阵列AS3矢量

    本文发布于:2023-11-23 16:04:30,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1622066.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:阵列   矢量

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!