Difference between revisions of "Table"
m |
|||
(One intermediate revision by the same user not shown) | |||
Line 12: | Line 12: | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
=== Methods === | === Methods === | ||
+ | [[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--> | ||
[[table.clone]] ''duplicates a table''<br/><!--GIDEROSMTD:table.clone(table,target,deepclone) duplicates a table--> | [[table.clone]] ''duplicates a table''<br/><!--GIDEROSMTD:table.clone(table,target,deepclone) duplicates a table--> | ||
[[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--> | [[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--> | ||
− | [[table. | + | [[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--> |
− | '''[ | + | [[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--> |
+ | [[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.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.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.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.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;"| |
Latest revision as of 06:15, 20 January 2023
Supported platforms:
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.
Methodstable.clear sets all keys in the given table to nil |
EventsConstants |