|
@@ -20,7 +20,7 @@
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
*/
|
|
|
package haxe;
|
|
|
-
|
|
|
+
|
|
|
private typedef VectorData<T> = #if flash10
|
|
|
flash.Vector<T>
|
|
|
#elseif neko
|
|
@@ -37,13 +37,13 @@ private typedef VectorData<T> = #if flash10
|
|
|
abstract Vector(VectorData<T>)<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.
|
|
|
**/
|
|
|
public inline function new(length:Int) {
|
|
@@ -63,62 +63,62 @@ abstract Vector(VectorData<T>)<T> {
|
|
|
|
|
|
/**
|
|
|
Returns the value at index [index].
|
|
|
-
|
|
|
+
|
|
|
If [index] is negative or exceeds [this].length, the result is
|
|
|
unspecified.
|
|
|
**/
|
|
|
- public inline function get(index:Int):Null<T> {
|
|
|
+ public inline function get(index:Int):Null<T> {
|
|
|
return this[index];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
Sets the value at index [index] to [val].
|
|
|
-
|
|
|
+
|
|
|
If [index] is negative or exceeds [this].length, the result is
|
|
|
unspecified.
|
|
|
**/
|
|
|
- public inline function set(index:Int, val:T):T {
|
|
|
+ public inline function set(index:Int, val:T):T {
|
|
|
return this[index] = val;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
Returns the length of [this] Vector.
|
|
|
**/
|
|
|
- public inline function length():Int {
|
|
|
+ public inline function length():Int {
|
|
|
#if neko
|
|
|
return untyped __dollar__asize(this);
|
|
|
#else
|
|
|
return untyped this.length;
|
|
|
#end
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
Extracts the data of [this] Vector.
|
|
|
-
|
|
|
+
|
|
|
This returns the internal representation type.
|
|
|
**/
|
|
|
public inline function toData():VectorData<T>
|
|
|
return cast this
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
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 public inline function fromData<T>(data:VectorData<T>):Vector<T>
|
|
|
return cast data
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
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 public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
|