forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
88
Kha/Tools/macos/std/php/_std/haxe/ds/IntMap.hx
Normal file
88
Kha/Tools/macos/std/php/_std/haxe/ds/IntMap.hx
Normal file
@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright (C)2005-2019 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package haxe.ds;
|
||||
|
||||
import php.Syntax;
|
||||
import php.Global;
|
||||
import php.NativeArray;
|
||||
import php.NativeIndexedArray;
|
||||
|
||||
@:coreApi class IntMap<T> implements haxe.Constraints.IMap<Int, T> {
|
||||
var data:NativeIndexedArray<T>;
|
||||
|
||||
public function new():Void {
|
||||
data = new NativeIndexedArray();
|
||||
}
|
||||
|
||||
public inline function set(key:Int, value:T):Void {
|
||||
data[key] = value;
|
||||
}
|
||||
|
||||
public inline function get(key:Int):Null<T> {
|
||||
return Syntax.coalesce(data[key], null);
|
||||
}
|
||||
|
||||
public inline function exists(key:Int):Bool {
|
||||
return Global.array_key_exists(key, data);
|
||||
}
|
||||
|
||||
public function remove(key:Int):Bool {
|
||||
if (Global.array_key_exists(key, data)) {
|
||||
Global.unset(data[key]);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public inline function keys():Iterator<Int> {
|
||||
return Global.array_keys(data).iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.iterator", "anon_optional_read.iterator", "anon_read.iterator")
|
||||
public inline function iterator():Iterator<T> {
|
||||
return Global.array_values(data).iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.keyValueIterator", "anon_optional_read.keyValueIterator", "anon_read.keyValueIterator")
|
||||
public inline function keyValueIterator():KeyValueIterator<Int, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public inline function copy():IntMap<T> {
|
||||
return Syntax.clone(this);
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var parts = new NativeArray();
|
||||
Syntax.foreach(data, function(key:Int, value:T) {
|
||||
Global.array_push(parts, '$key => ' + Std.string(value));
|
||||
});
|
||||
|
||||
return '{' + Global.implode(', ', parts) + '}';
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
data = new NativeIndexedArray();
|
||||
}
|
||||
}
|
97
Kha/Tools/macos/std/php/_std/haxe/ds/ObjectMap.hx
Normal file
97
Kha/Tools/macos/std/php/_std/haxe/ds/ObjectMap.hx
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (C)2005-2019 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package haxe.ds;
|
||||
|
||||
import php.*;
|
||||
|
||||
@:coreApi
|
||||
class ObjectMap<K:{}, V> implements haxe.Constraints.IMap<K, V> {
|
||||
var _keys:NativeAssocArray<K>;
|
||||
var _values:NativeAssocArray<V>;
|
||||
|
||||
public function new():Void {
|
||||
_keys = new NativeAssocArray();
|
||||
_values = new NativeAssocArray();
|
||||
}
|
||||
|
||||
public function set(key:K, value:V):Void {
|
||||
var id = Global.spl_object_hash(key);
|
||||
_keys[id] = key;
|
||||
_values[id] = value;
|
||||
}
|
||||
|
||||
public function get(key:K):Null<V> {
|
||||
var id = Global.spl_object_hash(key);
|
||||
return Global.isset(_values[id]) ? _values[id] : null;
|
||||
}
|
||||
|
||||
public function exists(key:K):Bool {
|
||||
return Global.array_key_exists(Global.spl_object_hash(key), _values);
|
||||
}
|
||||
|
||||
public function remove(key:K):Bool {
|
||||
var id = Global.spl_object_hash(key);
|
||||
if (Global.array_key_exists(id, _values)) {
|
||||
Global.unset(_keys[id], _values[id]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function keys():Iterator<K> {
|
||||
return _keys.iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.iterator", "anon_optional_read.iterator", "anon_read.iterator")
|
||||
public inline function iterator():Iterator<V> {
|
||||
return _values.iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.keyValueIterator", "anon_optional_read.keyValueIterator", "anon_read.keyValueIterator")
|
||||
public inline function keyValueIterator():KeyValueIterator<K, V> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public inline function copy():ObjectMap<K, V> {
|
||||
return Syntax.clone(this);
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var s = "{";
|
||||
var it = keys();
|
||||
for (i in it) {
|
||||
s += Std.string(i);
|
||||
s += " => ";
|
||||
s += Std.string(get(i));
|
||||
if (it.hasNext())
|
||||
s += ", ";
|
||||
}
|
||||
return s + "}";
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
_keys = new NativeAssocArray();
|
||||
_values = new NativeAssocArray();
|
||||
}
|
||||
}
|
89
Kha/Tools/macos/std/php/_std/haxe/ds/StringMap.hx
Normal file
89
Kha/Tools/macos/std/php/_std/haxe/ds/StringMap.hx
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright (C)2005-2019 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package haxe.ds;
|
||||
|
||||
import php.Syntax;
|
||||
import php.Global;
|
||||
import php.NativeArray;
|
||||
import php.NativeAssocArray;
|
||||
import haxe.Constraints;
|
||||
|
||||
@:coreApi class StringMap<T> implements IMap<String, T> {
|
||||
private var data:NativeAssocArray<T>;
|
||||
|
||||
public inline function new():Void {
|
||||
data = new NativeAssocArray();
|
||||
}
|
||||
|
||||
public inline function set(key:String, value:T):Void {
|
||||
data[key] = value;
|
||||
}
|
||||
|
||||
public inline function get(key:String):Null<T> {
|
||||
return Syntax.coalesce(data[key], null);
|
||||
}
|
||||
|
||||
public inline function exists(key:String):Bool {
|
||||
return Global.array_key_exists(key, data);
|
||||
}
|
||||
|
||||
public function remove(key:String):Bool {
|
||||
if (Global.array_key_exists(key, data)) {
|
||||
Global.unset(data[key]);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public inline function keys():Iterator<String> {
|
||||
return Global.array_map('strval', Global.array_keys(data)).iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.iterator", "anon_optional_read.iterator", "anon_read.iterator")
|
||||
public inline function iterator():Iterator<T> {
|
||||
return data.iterator();
|
||||
}
|
||||
|
||||
@:ifFeature("dynamic_read.keyValueIterator", "anon_optional_read.keyValueIterator", "anon_read.keyValueIterator")
|
||||
public inline function keyValueIterator():KeyValueIterator<String, T> {
|
||||
return new haxe.iterators.MapKeyValueIterator(this);
|
||||
}
|
||||
|
||||
public inline function copy():StringMap<T> {
|
||||
return Syntax.clone(this);
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
var parts = new NativeArray();
|
||||
Syntax.foreach(data, function(key:String, value:T) {
|
||||
Global.array_push(parts, '$key => ' + Std.string(value));
|
||||
});
|
||||
|
||||
return '{' + Global.implode(', ', parts) + '}';
|
||||
}
|
||||
|
||||
public inline function clear():Void {
|
||||
data = new NativeAssocArray();
|
||||
}
|
||||
}
|
133
Kha/Tools/macos/std/php/_std/haxe/ds/Vector.hx
Normal file
133
Kha/Tools/macos/std/php/_std/haxe/ds/Vector.hx
Normal file
@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C)2005-2019 Haxe Foundation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package haxe.ds;
|
||||
|
||||
import php.*;
|
||||
|
||||
private class PhpVectorData<T> {
|
||||
public var length:Int;
|
||||
public var data:NativeIndexedArray<T>;
|
||||
|
||||
public inline function new(length:Int) {
|
||||
this.length = length;
|
||||
data = new NativeIndexedArray();
|
||||
}
|
||||
}
|
||||
|
||||
private typedef VectorData<T> = PhpVectorData<T>;
|
||||
|
||||
abstract Vector<T>(VectorData<T>) {
|
||||
public var length(get, never):Int;
|
||||
|
||||
public inline function new(length:Int) {
|
||||
this = new VectorData(length);
|
||||
}
|
||||
|
||||
@:op([]) public inline function get(index:Int):T {
|
||||
return Syntax.coalesce(this.data[index], null);
|
||||
}
|
||||
|
||||
@:op([]) public inline function set(index:Int, val:T):T {
|
||||
return this.data[index] = val;
|
||||
}
|
||||
|
||||
inline function get_length():Int {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public static function blit<T>(src:Vector<T>, srcPos:Int, dest:Vector<T>, destPos:Int, len:Int):Void {
|
||||
if (src == dest) {
|
||||
if (srcPos < destPos) {
|
||||
var i = srcPos + len;
|
||||
var j = destPos + len;
|
||||
for (k in 0...len) {
|
||||
i--;
|
||||
j--;
|
||||
src[j] = src[i];
|
||||
}
|
||||
} else if (srcPos > destPos) {
|
||||
var i = srcPos;
|
||||
var j = destPos;
|
||||
for (k in 0...len) {
|
||||
src[j] = src[i];
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (i in 0...len) {
|
||||
dest[destPos + i] = src[srcPos + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function toArray():Array<T> {
|
||||
var result = [];
|
||||
@:privateAccess result.length = length;
|
||||
for (i in 0...length) {
|
||||
@:privateAccess result.arr.push(get(i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public inline function toData():VectorData<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
static public inline function fromData<T>(data:VectorData<T>):Vector<T> {
|
||||
return cast data;
|
||||
}
|
||||
|
||||
static public inline function fromArrayCopy<T>(array:Array<T>):Vector<T> {
|
||||
var vectorData = new VectorData(array.length);
|
||||
vectorData.data = @:privateAccess array.arr;
|
||||
return cast vectorData;
|
||||
}
|
||||
|
||||
public inline function copy<T>():Vector<T> {
|
||||
return cast Syntax.clone(this);
|
||||
}
|
||||
|
||||
public function join<T>(sep:String):String {
|
||||
if (this.length == 0) {
|
||||
return '';
|
||||
}
|
||||
var result = Std.string(get(0));
|
||||
for (i in 1...this.length) {
|
||||
result = Syntax.concat(result, Syntax.concat(sep, Std.string(get(i))));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public inline function map<S>(f:T->S):Vector<S> {
|
||||
var result = new Vector(this.length);
|
||||
Syntax.foreach(this.data, function(key:Int, value:T) {
|
||||
result[key] = f(value);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public inline function sort<T>(f:T->T->Int):Void {
|
||||
Global.usort(this.data, f);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user