简体   繁体   English

使用数组 - Vector 类型初始化 AS 3.0 向量。<array> ? (加上C++等价物)</array>

[英]Initializing a AS 3.0 vector with type array - Vector.<Array>? (plus C++ equivelant)

I have a quick question for you all.我有一个简短的问题要问大家。 I'm trying to convert over some ActionScript code to C++ and am having a difficult time with this one line:我正在尝试将一些 ActionScript 代码转换为 C++ 并且在使用这一行时遇到了困难:

private var edges:Vector.<Array>

What is this exactly?这究竟是什么? Is this essentially a multidimensional vector then?那么这本质上是一个多维向量吗? Or is this simply declaring the vector as a container?或者这只是将向量声明为容器? I understand from researching that vectors, like C++ vectors, have to be declared with a type.我从研究中了解到,必须使用类型声明向量,例如 C++ 向量。 However, in C++ I can't just put down Array, I have to use another vector (probably) so it looks like:但是,在 C++ 中,我不能只放下 Array,我必须使用另一个向量(可能),所以它看起来像:

vector<vector<T> example;

or possibly even甚至可能

vector<int[]> example;

I don't expect you guys to know the C++ equivalent because I'm primarily posting this with AS tags, but if you could confirm my understand of the AS half, that would be great.我不希望你们知道 C++ 等价物,因为我主要使用 AS 标签发布此内容,但如果您能确认我对 AS 部分的理解,那就太好了。 I did some googling but didn't find any cases where someone used Array as it's type.我做了一些谷歌搜索,但没有发现有人使用 Array 作为类型的任何情况。

From Mike Chambers (adobe evangelist):来自 Mike Chambers(adobe 传道者):

"Essentially, the Vector class is a typed Array, and in addition to ensuring your collection is type safe, can also provide (sometimes significant) performance improvements over using an Array." “从本质上讲,Vector class 是一个类型化数组,除了确保您的集合是类型安全的之外,还可以提供(有时是显着的)比使用数组的性能改进。”

http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/ http://www.mikechambers.com/blog/2008/08/19/using-vectors-in-actionscript-3-and-flash-player-10/

Essentially the vector in C++ is based on the same principles. C++ 中的向量本质上是基于相同的原理。 As far as porting a vector of Arrays in AS3 to C++, well that's not a conversion that is clear cut in principle, as you could have a collection (array) of various types in C++, such as a char array.至于将 AS3 中的 Arrays 的向量移植到 C++,这在原则上并不是一个明确的转换,因为您可以在 ZF6F87C9FDCF8B3C3F07F93F1EE8 中拥有各种类型的集合(数组),例如数组。 However, it appears you've got the idea, as you've pretty much posted examples of both avenues in your question.但是,您似乎已经有了这个想法,因为您已经在问题中发布了这两种途径的示例。

I would post some code but I think you've got it exactly.我会发布一些代码,但我认为你已经明白了。 Weather you use a vector within a vector or you declare a specifically typed collection I think comes down to a matter of what works best for you specific project.天气你在一个向量中使用一个向量,或者你声明一个特定类型的集合,我认为归结为最适合你的特定项目的问题。

Also you might be interested in:此外,您可能对以下内容感兴趣:

http://www.mikechambers.com/blog/2008/09/24/actioscript-3-vector-array-performance-comparison/ http://www.mikechambers.com/blog/2008/09/24/actioscript-3-vector-array-performance-comparison/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM