forked from LeenkxTeam/LNXSDK
Update Files
This commit is contained in:
50
Kha/Tools/macos/std/php/_std/haxe/Rest.hx
Normal file
50
Kha/Tools/macos/std/php/_std/haxe/Rest.hx
Normal file
@ -0,0 +1,50 @@
|
||||
package haxe;
|
||||
|
||||
import php.*;
|
||||
import haxe.iterators.RestIterator;
|
||||
import haxe.iterators.RestKeyValueIterator;
|
||||
|
||||
private typedef NativeRest<T> = NativeIndexedArray<T>;
|
||||
|
||||
@:coreApi
|
||||
@:semantics(value)
|
||||
abstract Rest<T>(NativeRest<T>) {
|
||||
public var length(get,never):Int;
|
||||
inline function get_length():Int
|
||||
return Global.count(this);
|
||||
|
||||
@:from
|
||||
static public inline function of<T>(array:Array<T>):Rest<T>
|
||||
return new Rest(@:privateAccess array.arr);
|
||||
|
||||
inline function new(a:NativeIndexedArray<T>):Void
|
||||
this = a;
|
||||
|
||||
@:arrayAccess inline function get(index:Int):T
|
||||
return this[index];
|
||||
|
||||
@:to public inline function toArray():Array<T>
|
||||
return @:privateAccess Array.wrap(this);
|
||||
|
||||
public inline function iterator():RestIterator<T>
|
||||
return new RestIterator<T>(this);
|
||||
|
||||
public inline function keyValueIterator():RestKeyValueIterator<T>
|
||||
return new RestKeyValueIterator<T>(this);
|
||||
|
||||
public inline function append(item:T):Rest<T> {
|
||||
var result = this;
|
||||
result.push(item);
|
||||
return new Rest(result);
|
||||
}
|
||||
|
||||
public inline function prepend(item:T):Rest<T> {
|
||||
var result = this;
|
||||
Global.array_unshift(result, item);
|
||||
return new Rest(result);
|
||||
}
|
||||
|
||||
public function toString():String {
|
||||
return inline Boot.stringifyNativeIndexedArray(this);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user