ds.Vector

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

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

read only length:Int

Returns the length of this Vector.

Methods

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.

inline get (index:Int):T

Returns the value at index index.

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

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

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

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

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

inline toData ():VectorData<T>

Extracts the data of this Vector.

This returns the internal representation type.

Static methods

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

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

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部