Difference between revisions of "Table"

From GiderosMobile
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' android, ios, mac, pc<br/>
+
<!--GIDEROSOBJ:table-->
 +
'''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 +
 
=== Description ===
 
=== Description ===
<translate>This library provides generic functions for table manipulation. It provides all its functions inside the table table.  
+
This library provides generic functions for table manipulation.
  
 +
Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the "length" of a table we mean the result of the length operator.
  
Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the "length" of a table we mean the result of the length operator.</translate>
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[Special:MyLanguage/table.concat|table.concat]] ''<translate>returns concatenated table elements i to j separated by sep</translate>''<br/>
+
[[table.clear]] ''sets all keys in the given table to nil''<br/><!--GIDEROSMTD:table.clear(t) sets all keys in the given table to nil-->
[[Special:MyLanguage/table.getn|table.getn]] ''<translate>returns size of table, or n field, or table.setn value, or 1 less first index with nil value
+
[[table.clone]] ''duplicates a table''<br/><!--GIDEROSMTD:table.clone(table,target,deepclone) duplicates a table-->
[Deprecated in Lua 5.1, use # operator]</translate>''<br/>
+
[[table.concat]] ''returns concatenated table elements i to j separated by sep''<br/><!--GIDEROSMTD:table.concat(table,sep,i,j) returns concatenated table elements i to j separated by sep-->
[[Special:MyLanguage/table.insert|table.insert]] ''<translate>insert value at location pos in table, default pos=n 1</translate>''<br/>
+
[[table.create]] ''creates a table with the array portion allocated to the given number of elements''<br/><!--GIDEROSMTD:table.create(count,value) creates a table with the array portion allocated to the given number of elements-->
[[Special:MyLanguage/table.remove|table.remove]] ''<translate>removes element at pos from table, default pos=n</translate>''<br/>
+
[[table.find]] ''returns the index of the first occurrence of what within table starting from init''<br/><!--GIDEROSMTD:table.find(table,what,init) returns the index of the first occurrence of what within table starting from init-->
[[Special:MyLanguage/table.sort|table.sort]] ''<translate>sorts in-place elements 1 to n, comp(v1,v2- true if v1<v2, default <</translate>''<br/>
+
[[table.foreach]] ''iterates over the provided table, passing the key and value of each iteration over to the provided function''<br/><!--GIDEROSMTD:table.foreach(table,function) iterates over the provided table, passing the key and value of each iteration over to the provided function-->
 +
[[table.foreachi]] ''similar to table.foreach() except index-value pairs are passed instead of key-value pairs''<br/><!--GIDEROSMTD:table.foreachi(t,function) similar to table.foreach() except index-value pairs are passed instead of key-value pairs-->
 +
[[table.freeze]] ''makes the given table read-only''<br/><!--GIDEROSMTD:table.freeze(t) makes the given table read-only-->
 +
[[table.getn]] ''returns the number of elements in the table passed''<br/><!--GIDEROSMTD:table.getn(t) returns the number of elements in the table passed-->
 +
[[table.insert]] ''inserts value at location pos in table, default pos=n 1''<br/><!--GIDEROSMTD:table.insert(table,pos,value) inserts value at location pos in table, default pos=n 1-->
 +
[[table.isfrozen]] ''returns true if the given table is frozen and false if it isn't frozen''<br/><!--GIDEROSMTD:table.isfrozen(t) returns true if the given table is frozen and false if it isn't frozen-->
 +
[[table.maxn]] ''returns the maximum numeric key of the provided table, or zero if the table has no numeric keys''<br/><!--GIDEROSMTD:table.maxn(t) returns the maximum numeric key of the provided table, or zero if the table has no numeric keys-->
 +
[[table.move]] ''copies the specified range of elements from one table to another''<br/><!--GIDEROSMTD:table.move(src,a,b,t,dst) copies the specified range of elements from one table to another-->
 +
[[table.pack]] ''returns a new table containing the provided values''<br/><!--GIDEROSMTD:table.pack(values...) returns a new table containing the provided values-->
 +
[[table.remove]] ''removes element at pos from table, default pos=n''<br/><!--GIDEROSMTD:table.remove(table,pos) removes element at pos from table, default pos=n-->
 +
[[table.share]] ''makes a table thread safe''<br/><!--GIDEROSMTD:table.share(table) makes a table thread safe-->
 +
[[table.sort]] ''sorts in-place elements 1 to n, comp(v1,v2- true if v1<v2, default <)''<br/><!--GIDEROSMTD:table.sort(table,comp) sorts in-place elements 1 to n, comp(v1,v2- true if v1<v2, default <)-->
 +
[[table.unpack]] ''returns all elements from the given list as a tuple''<br/><!--GIDEROSMTD:table.unpack(list,i,j) returns all elements from the given list as a tuple-->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}
 +
 +
{{GIDEROS IMPORTANT LINKS}}

Latest revision as of 06:15, 20 January 2023

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6

Description

This library provides generic functions for table manipulation.

Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the "length" of a table we mean the result of the length operator.

Methods

table.clear sets all keys in the given table to nil
table.clone duplicates a table
table.concat returns concatenated table elements i to j separated by sep
table.create creates a table with the array portion allocated to the given number of elements
table.find returns the index of the first occurrence of what within table starting from init
table.foreach iterates over the provided table, passing the key and value of each iteration over to the provided function
table.foreachi similar to table.foreach() except index-value pairs are passed instead of key-value pairs
table.freeze makes the given table read-only
table.getn returns the number of elements in the table passed
table.insert inserts value at location pos in table, default pos=n 1
table.isfrozen returns true if the given table is frozen and false if it isn't frozen
table.maxn returns the maximum numeric key of the provided table, or zero if the table has no numeric keys
table.move copies the specified range of elements from one table to another
table.pack returns a new table containing the provided values
table.remove removes element at pos from table, default pos=n
table.share makes a table thread safe
table.sort sorts in-place elements 1 to n, comp(v1,v2- true if v1<v2, default <)
table.unpack returns all elements from the given list as a tuple

Events

Constants