File TableUtils.lua
-- Table Utils -- --
Functions
__printTable (k, v) | __printTable( k, v ) |
listAdd (list, what) | listAdd( list, what ) |
listPrint (map) | listPrint( map ) |
listRemove (list, what) | listRemove( list, what ) |
printTable (map) | Function shows the content of a Lua table on the screen. |
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 a non-numerical table. |
table.union (...) | Table Union. |
table:update (t1, t2) | table:update(t1, t2) |
Functions
- __printTable (k, v)
-
__printTable( k, v )
Parameters
- k:
- v:
- listAdd (list, what)
-
listAdd( list, what )
Parameters
- list:
- what:
- listPrint (map)
-
listPrint( map )
Parameters
- map:
- listRemove (list, what)
-
listRemove( list, what )
Parameters
- list:
- what:
- printTable (map)
-
Function shows the content of a Lua table on the screen.
Parameters
- map:
- table.complement (set1, set2)
-
Table Complement.
Parameters
- set1:
- set2:
Return value:
- 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
- ...:
Usage:
- 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 }, }
Return value:
- 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:
- table.n_complement (set1, set2)
-
Table Complement.
Parameters
- set1:
- set2:
Return value:
- 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
- ...:
Return value:
- 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
- ...:
Return value:
- 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 a non-numerical table.
Parameters
- t:
- table.union (...)
-
Table Union.
Parameters
- ...:
Usage:
- 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, }
Return value:
- 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)
-
table:update(t1, t2)
Parameters
- t1:
- t2: