abstract haxe.ds.Vector<T>(VectorData<T>)

Available on all platforms

A Vector is a storage of fixed size. It can be faster than Array on some targets, and is never slower.

Class Fields

function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void

Copies length of elements from src Vector, beginning at srcPos to dest Vector, beginning at destPos

The results are unspecified if length results in out-of-bounds access, or if src or dest are null

function fromArrayCopy<T>(array:Array<T>):Vector<T>

Creates a new Vector by copying the elements of array.

This always creates a copy, even on platforms where the internal representation is Array.

The elements are not copied and retain their identity, so a[i] == Vector.fromArrayCopy(a).get(i) is true for any valid i.

If array is null, the result is unspecified.

function fromData<T>(data:VectorData<T>):Vector<T>

Initializes a new Vector from data.

Since data is the internal representation of Vector, this is a no-op.

If data is null, the corresponding Vector is also null.

Instance Fields

var length:Int

Returns the length of this Vector.

function new(length:Int):VectorData<T>

Creates a new Vector of length length.

Initially this Vector contains length neutral elements:

  • always null on dynamic targets
  • 0, 0.0 or false for Int, Float and Bool respectively on static targets
  • null for other types on static targets

If length is less than or equal to 0, the result is unspecified.

function get(index:Int):Null<T>

Returns the value at index index.

If index is negative or exceeds this.length, the result is unspecified.

function set(index:Int, val:T):T

Sets the value at index index to val.

If index is negative or exceeds this.length, the result is unspecified.

function toArray():Array<T>

Creates a new Array, copy the content from the Vector to it, and returns it.

function toData():VectorData<T>

Extracts the data of this Vector.

This returns the internal representation type.