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 also:
Static methods
staticblit<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
staticinlinefromArrayCopy<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.
staticinlinefromData<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
.
Variables
read onlylength:Int
Returns the length of this
Vector.
Methods
inlinecopy<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.
inlineget(index:Int):T
Returns the value at index index
.
If index
is negative or exceeds this.length
, the result is unspecified.
join<T>(sep:String):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.
inlinemap<S>(f:T ‑> S):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.
inlineset(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.
inlinesort<T>(f:(T, T) ‑> Int):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.
toArray():Array<T>
Creates a new Array, copy the content from the Vector to it, and returns it.
inlinetoData():VectorData<T>
Extracts the data of this
Vector.
This returns the internal representation type.
© 2005–2020 Haxe Foundation
Licensed under a MIT license.
https://api.haxe.org/haxe/ds/Vector.html