W3cubDocs

/Haxe Flash

Vector<T>

package flash

Available on flash

The Vector class is very similar to Array but is only supported by the Flash Player 10+

Static methods

staticinlineconvert<T, U>(v:Vector<T>):Vector<U>

staticinlineofArray<T>(v:Array<T>):Vector<T>

staticinlinetypeReference<T>():Class<Vector<T>>

Get a run-time value referencing the Vector class with concrete type parameters.

Normally in Haxe, for most of the types, type parameters are eliminated at run-time, so there is no way to check if a value is of a type with specific type parameters.

However, on the Flash target, the flash.Vector<T> values carry type parameter information at run-time all the type-checks (such as Std.isOfType and Std.downcast) on them must be done using a Class<T> value that also carries the type parameters. However, Haxe syntax does not allow creating such values and this function exists to mitigate this limitation.

It should be used as such:

var specificVectorType:Class<Vector<Int>> = Vector.typeReference();
trace(Std.isOfType(vec, specificVectorType));

or using the type-check syntax:

trace(Std.isOfType(vec, (Vector.typeReference() : Class<Vector<Int>>)));

It's also helpful when working with native Flash libraries, that receive Class instances:

new Signal((Vector.typeReference() : Class<Vector<Int>>));

Constructor

new(?length:UInt, ?fixed:Bool)

Variables

fixed:Bool

length:Int

removeAt:(index:Int) ‑> T

Methods

concat(?a:Vector<T>):Vector<T>

indexOf(x:T, ?from:Int):Int

inlineinsertAt(index:Int, element:T):Void

join(sep:String):String

lastIndexOf(x:T, ?from:Int):Int

pop():Null<T>

push(x:T):Int

reverse():Void

shift():Null<T>

slice(?pos:Int, ?end:Int):Vector<T>

sort(f:(T, T) ‑> Int):Void

splice(pos:Int, len:Int):Vector<T>

toString():String

unshift(x:T):Void

© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/flash/Vector.html