W3cubDocs

/Haxe

Vector<T>(VectorData<T>)

package haxe.ds

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.

See:

Constructor

@:impl inline new (length:Int)

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.

Variables

@:impl read only length:Int

Returns the length of this Vector.

Methods

@:impl inline copy<T> ():Vector<T>

Returns a shallow copy of this Vector.

The elements are not copied and retain their identity, so a[i] == a.copy()[i] is true for any valid i. However, a == a.copy() is always false.

@:impl @:op([]) inline get (this:VectorData<T>):T

Returns the value at index index.

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

@:impl inline join<T> (this:VectorData<T>):String

Returns a string representation of this Vector, with sep separating each element.

The result of this operation is equal to Std.string(this[0]) + sep + Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])

If this Vector has length 0, the result is the empty String "". If this has exactly one element, the result is equal to a call to Std.string(this[0]).

If sep is null, the result is unspecified.

@:impl inline map<S> (this:VectorData<T>):Vector<S>

Creates a new Vector by applying function f to all elements of this.

The order of elements is preserved.

If f is null, the result is unspecified.

@:impl @:op([]) inline set (this:VectorData<T>, index:Int):T

Sets the value at index index to val.

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

@:impl inline sort<T> (this:VectorData<T>):Void

Sorts this Vector according to the comparison function f, where f(x,y) returns 0 if x == y, a positive Int if x > y and a negative Int if x < y.

This operation modifies this Vector in place.

The sort operation is not guaranteed to be stable, which means that the order of equal elements may not be retained.

If f is null, the result is unspecified.

@:impl toArray ():Array<T>

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

@:impl inline toData ():VectorData<T>

Extracts the data of this Vector.

This returns the internal representation type.

Static variables

@:impl static read only length:Int

Returns the length of this Vector.

Static methods

@:impl static inline new (length:Int)

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.

static 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

static 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

@:impl static inline copy<T> ():Vector<T>

Returns a shallow copy of this Vector.

The elements are not copied and retain their identity, so a[i] == a.copy()[i] is true for any valid i. However, a == a.copy() is always false.

static inline 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.

static inline 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.

static inline 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.

static inline 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.

@:impl @:op([]) static inline get (this:VectorData<T>):T

Returns the value at index index.

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

@:impl static inline join<T> (this:VectorData<T>):String

Returns a string representation of this Vector, with sep separating each element.

The result of this operation is equal to Std.string(this[0]) + sep + Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])

If this Vector has length 0, the result is the empty String "". If this has exactly one element, the result is equal to a call to Std.string(this[0]).

If sep is null, the result is unspecified.

@:impl static inline map<S> (this:VectorData<T>):Vector<S>

Creates a new Vector by applying function f to all elements of this.

The order of elements is preserved.

If f is null, the result is unspecified.

@:impl @:op([]) static inline set (this:VectorData<T>, index:Int):T

Sets the value at index index to val.

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

@:impl static inline sort<T> (this:VectorData<T>):Void

Sorts this Vector according to the comparison function f, where f(x,y) returns 0 if x == y, a positive Int if x > y and a negative Int if x < y.

This operation modifies this Vector in place.

The sort operation is not guaranteed to be stable, which means that the order of equal elements may not be retained.

If f is null, the result is unspecified.

@:impl static toArray ():Array<T>

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

@:impl static inline toData ():VectorData<T>

Extracts the data of this Vector.

This returns the internal representation type.

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