This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -227,7 +227,7 @@ class BalancedTree<K, V> implements haxe.Constraints.IMap<K, V> {
}
public function toString() {
return root == null ? '{}' : '{${root.toString()}}';
return root == null ? "[]" : '[${root.toString()}]';
}
/**
@ -264,6 +264,6 @@ class TreeNode<K, V> {
return this == null ? 0 : _height;
public function toString() {
return (left == null ? "" : left.toString() + ", ") + '$key=$value' + (right == null ? "" : ", " + right.toString());
return (left == null ? "" : left.toString() + ", ") + '$key => $value' + (right == null ? "" : ", " + right.toString());
}
}

View File

@ -33,11 +33,25 @@ class EnumValueMap<K:EnumValue, V> extends haxe.ds.BalancedTree<K, V> implements
var d = k1.getIndex() - k2.getIndex();
if (d != 0)
return d;
#if hl
var a1 = @:privateAccess Type._enumParameters(k1);
var a2 = @:privateAccess Type._enumParameters(k2);
var ld = a1.length - a2.length;
if (ld != 0)
return ld;
for (i in 0...a1.length) {
var d = compareArg(a1[i], a2[i]);
if (d != 0)
return d;
}
return 0;
#else
var p1 = k1.getParameters();
var p2 = k2.getParameters();
if (p1.length == 0 && p2.length == 0)
return 0;
return compareArgs(p1, p2);
#end
}
function compareArgs(a1:Array<Dynamic>, a2:Array<Dynamic>):Int {

View File

@ -24,9 +24,7 @@ package haxe.ds;
import haxe.ds.StringMap;
import haxe.ds.IntMap;
import haxe.ds.HashMap;
import haxe.ds.ObjectMap;
import haxe.ds.WeakMap;
import haxe.ds.EnumValueMap;
import haxe.Constraints.IMap;

View File

@ -41,7 +41,7 @@ private typedef VectorData<T> =
eval.Vector<T>
#else
Array<T>
#end
#end;
/**
A Vector is a storage of fixed size. It can be faster than Array on some
@ -61,7 +61,7 @@ abstract Vector<T>(VectorData<T>) {
If `length` is less than or equal to 0, the result is unspecified.
**/
public inline function new(length:Int) {
extern overload public inline function new(length:Int) {
#if flash10
this = new flash.Vector<T>(length, true);
#elseif neko
@ -75,7 +75,7 @@ abstract Vector<T>(VectorData<T>) {
#elseif cpp
this = NativeArray.create(length);
#elseif python
this = python.Syntax.code("[{0}]*{1}", null, length);
this = python.Syntax.code("([{0}]*{1})", null, length);
#elseif lua
this = untyped __lua_table__({length: length});
#elseif eval
@ -86,6 +86,43 @@ abstract Vector<T>(VectorData<T>) {
#end
}
/**
Creates a new Vector of length `length` filled with `defaultValue` elements.
Can be faster than `new Vector(length)` for iteration on some targets for non-nullable elements.
If `length` is less than or equal to 0, the result is unspecified.
**/
extern overload public inline function new(length:Int, defaultValue:T):Vector<T> {
#if js
this = [for (_ in 0...length) defaultValue];
#elseif python
this = python.Syntax.code("([{0}]*{1})", defaultValue, length);
#else
#if flash10
this = new flash.Vector<T>(length, true);
#elseif neko
this = untyped __dollar__amake(length);
#elseif cs
this = new cs.NativeArray(length);
#elseif java
this = new java.NativeArray(length);
#elseif cpp
this = NativeArray.create(length);
#elseif lua
this = untyped __lua_table__({length: length});
#elseif eval
this = new eval.Vector(length);
#else
this = [];
untyped this.length = length;
#end
fill(defaultValue);
#end
}
/**
Returns the value at index `index`.
@ -141,6 +178,12 @@ abstract Vector<T>(VectorData<T>) {
#end
}
/**
Sets all `length` elements of `this` Vector to `value`.
**/
public inline function fill(value:T):Void
for (i in 0...length) this[i] = value;
/**
Copies `length` of elements from `src` Vector, beginning at `srcPos` to
`dest` Vector, beginning at `destPos`