-
Notifications
You must be signed in to change notification settings - Fork 0
Table API
Read-only utility class for modifying or creating tables
Constructs a read-only view into a table
Read-only tables cannot be modified. Mutating the resulting table will result in Error.UNSUPPORTED_OPERATION. getmetatable yields a function which returns the length of the underlying table (equivalent to #private. Calling # on the read-only table is unsupported due to __len meta method not being present in Lua 5.1.
| Parameter | Type | Description | Requirement |
|---|---|---|---|
private |
table |
Internal fields of the table | Required |
meta_methods |
table |
Meta methods to be included into the resulting table | Optional |
-
returns [
table] Read-only wrapper of specified table
Fetches the key’s value, or sets and returns a default value if absent
If default value is dynamic, use put_compute(tbl, key, computer).
| Parameter | Type | Description | Requirement |
|---|---|---|---|
tbl |
table |
Table to query | Required |
key |
Any | Key of the pairing | Required |
default_value |
Paired value if the key is absent | Required |
-
returns
[Any]Resulting value of the key-value pairing
Fetches the key’s value, or sets and returns a computed value if absent
If the computed value is a constant, use put_default(tbl, key, default_value).
| Parameter | Type | Description | Requirement |
|---|---|---|---|
tbl |
table |
Table to query | Required |
key |
Any | Key of the pairing | Required |
computer |
function |
[Any] callback([Any])
|
Required |
-
returns
[Any]Resulting value of the key-value pairing
Constructs a set of specified values
Each key of the set is associated with true.
nil elements are ignored from the set.
| Parameter | Type | Description | Requirement |
|---|---|---|---|
... |
Any | Elements of the resulting set | Required |
-
returns
[table]Set of specified values
Sorts a table using the specified comparator
Implementation uses two-part recursive Quicksort. This sort is not stable. Runtime should be similar to Lua's table.sort.
| Parameter | Type | Description | Requirement |
|---|---|---|---|
tbl |
table |
Table to be sorted | Required |
comparator |
function |
[Number] callback([Any], [Any])
|
Required |
-
returns
nil