File TableUtils.lua
Functions
listAdd (list, what) | TODO listAdd( list, what ) |
listPrint (map) | Lua debug function that prints the content of a Lua table on the screen. |
listRemove (list, what) | TODO listRemove( list, what ) |
printTable (map) | Lua debug function that prints the content of a Lua table on the screen, split up in keys and values. |
table.complement (set1, set2) | Table Complement. |
table.contains (t, value) | Determines if a table contains a value as a key or as a value (recursive). |
table.intersection (...) | Table Intersection. |
table.is_empty (tbl) | Tests if a table is empty: this is useful in situations where you find yourself wanting to do 'if my_table == {}' and such. |
table.n_complement (set1, set2) | Table Complement. |
table.n_intersection (...) | Table Intersection. |
table.n_union (...) | Table Union. |
table.size (t) | Gets the actual size of non-index based tables. |
table.union (...) | Table Union. |
table:update (t1, t2) | TODO table:update(t1, t2) |
Functions
- listAdd (list, what)
-
TODO listAdd( list, what )
Parameters- list:
- what:
- listPrint (map)
-
Lua debug function that prints the content of a Lua table on the screen.
There are currently 3 functions with similar behaviour.
Parameters- map:
- listRemove (list, what)
-
TODO listRemove( list, what )
Parameters- list:
- what:
- printTable (map)
-
Lua debug function that prints the content of a Lua table on the screen, split up in keys and values. Useful if you want to see what the capture groups contain i. e. the Lua table "matches".
Parameters- map:
- table.complement (set1, set2)
-
Table Complement.
Parameters- set1:
- set2:
- Returns a table that is the relative complement of the first table with respect to the second table. Returns a complement of key/value pairs.
- table.contains (t, value)
-
Determines if a table contains a value as a key or as a value (recursive).
Parameters- t:
- value:
- table.intersection (...)
-
Table Intersection.
Parameters- ...:
- Example:
tableA = { [1] = 123, [2] = 456, [4] = { 1, 2 }, [5] = "c", ["test"] = "test", } tableB = { [1] = 123, [2] = 4, [3] = 7, [4] = { 1, 2 }, ["test"] = function() return true end, } tableC = { [1] = 123, [4] = { 1, 2 }, [5] = "c", } table.intersection(tableA, tableB, tableC) will return: { [1] = 123, [4] = { 1, 2 }, }
- Returns a table that is the intersection of the provided tables. This is an intersection of key/value pairs. See table.n_intersection() for an intersection of values. Note that the resulting table may not be reliably traversable with ipairs() due to the fact that it preserves keys. If there is a gap in numerical indices, ipairs() will cease traversal.
- table.is_empty (tbl)
-
Tests if a table is empty: this is useful in situations where you find yourself wanting to do 'if my_table == {}' and such.
Parameters- tbl:
- Testing if the table is empty.
myTable = {} if table.is_empty(myTable) then echo("myTable is empty") end
- table.n_complement (set1, set2)
-
Table Complement.
Parameters- set1:
- set2:
- Returns a table that is the relative complement of the first table with respect to the second table. Returns a complement of values.
- table.n_intersection (...)
-
Table Intersection.
Parameters- ...:
- Returns a numerically indexed table that is the intersection of the provided tables. This is an intersection of unique values. The order and keys of the input tables are not preserved.
- table.n_union (...)
-
Table Union.
Parameters- ...:
- Returns a numerically indexed table that is the union of the provided tables. This is a union of unique values. The order and keys of the input tables are not preserved.
- table.size (t)
-
Gets the actual size of non-index based tables.
For index based tables you can get the size with the # operator:
This is the standard Lua way of getting the size of index tables i.e. ipairs() type of tables with numerical indices. To get the size of tables that use user defined keys instead of automatic indices (pairs() type) you need to use the function table.size() referenced above.myTableSize = # myTable
Parameters- t:
- table.union (...)
-
Table Union.
Parameters- ...:
- Example:
tableA = { [1] = 123, [2] = 456, ["test"] = "test", } tableB = { [1] = 23, [3] = 7, ["test2"] = function() return true end, } tableC = { [5] = "c", } table.union(tableA, tableB, tableC) will return: { [1] = { 123, 23, }, [2] = 456, [3] = 7, [5] = "c", ["test"] = "test", ["test2"] = function() return true end, }
- Returns a table that is the union of the provided tables. This is a union of key/value pairs. If two or more tables contain different values associated with the same key, that key in the returned table will contain a subtable containing all relevant values. See table.n_union() for a union of values. Note that the resulting table may not be reliably traversable with ipairs() due to the fact that it preserves keys. If there is a gap in numerical indices, ipairs() will cease traversal.
- table:update (t1, t2)
-
TODO table:update(t1, t2)
Parameters- t1:
- t2: