File: Table.hx

package info (click to toggle)
haxe 1%3A3.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 29,888 kB
  • sloc: ml: 106,129; ansic: 1,978; makefile: 609; cpp: 357; java: 349; cs: 323; python: 250; sh: 75; objc: 64; xml: 29
file content (36 lines) | stat: -rw-r--r-- 1,253 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package lua;

/**
	This library provides generic functions for table manipulation.
**/
// TODO: use an abstract here?
@:native("_G.table")
extern class Table<A,B> implements ArrayAccess<B> implements Dynamic<B> {

	@:analyzer(no_fusion)
	public inline static function create<A,B>(?arr:Array<B>, ?hsh:Dynamic) : Table<A,B> {
		return untyped __lua_table__(arr,hsh);
	}

	@:overload(function<A,B>(table:Table<A,B>):Void{})
	public static function concat<A,B>(table:Table<A,B>, ?sep:String) : String;

	public static function foreach<A,B>(table:Table<A,B>, f:A->B->Void) : Void;
	public static function foreachi<A,B>(table:Table<A,B>, f:A->B->Int->Void) : Void;

	public static function sort<A,B>(table:Table<A,B>, ?order : A->A->Bool) : Void;

	@:overload(function<B>(table:Table<Int,B>, value:B):Void{})
	public static function insert<B>(table:Table<Int,B>, pos:Int, value:B) : Void;

	@:overload(function<B>(table:Table<Int,B>):Void{})
	public static function remove<B>(table:Table<Int,B>, ?pos:Int) : Void;

#if (lua_ver >= 5.2)
	public static function pack<T>(args:haxe.extern.Rest<T>) : Table<Int,T>;
	public static function unpack<Int,V>(args:lua.Table<Int,V>, ?min : Int, ?max : Int) : Dynamic;
#end

}

typedef AnyTable = Table<Dynamic, Dynamic>;