Module gears.table - awesome API documentation

# Module `gears.table`

Table module for gears

## Functions

join (...) | Join all tables given as arguments.
crush (t, set[, raw=false]) | Override elements in the first table by the one in the second.
from_sparse (t) | Pack all elements with an integer key into a new table.
hasitem (t, item) | Check if a table has an item and return its key.
gtable.find_keys (t, matcher[, ordered=false[, max=nil]]) | Get all matching table keys for a `matcher` function.
gtable.find_first_key (t, matcher[, ordered=false]) | Find the first key that matches a function.
keys (t) | Get a sorted table with all integer keys from a table.
keys_filter (t, ...) | Filter a table's keys for certain content type.
reverse (t) | Reverse a table.
clone (t[, deep=true]) | Clone a table.
iterate (t, filter, start) | Iterate over a table.
merge (t, set) | Merge items from one table to another one.
map (f, tbl) | Map a function to a table.

## Functions

Methods

join (...)
  Join all tables given as arguments. This will iterate over all tables and insert their entries into a new table.
  - ... table Tables to join.

  ### Returns:

  table A new table containing all entries from the arguments.
crush (t, set[, raw=false])
  Override elements in the first table by the one in the second.

  Note that this method doesn't copy entries found in `__index`.

  - t table the table to be overriden
  - set table the table used to override members of `t`
  - raw bool Use rawset (avoid the metatable) (default false)

  ### Returns:

  table t (for convenience)
from_sparse (t)
  Pack all elements with an integer key into a new table. While both lua and luajit implement __len over sparse tables, the standard defines it as an implementation detail.

  This function removes any entries with non-numeric keys.

  - t table A potentially sparse table.

  ### Returns:

  table A packed table with only numeric keys.
hasitem (t, item)
  Check if a table has an item and return its key.
  - t table The table.
  - item The item to look for in values of the table.

  ### Returns:

  string or number The key of the item.

  ### Or

  nil
gtable.find_keys (t, matcher[, ordered=false[, max=nil]])
  Get all matching table keys for a `matcher` function.
  - t table The table.
  - matcher function A function taking the key and value as arguments and returning a boolean.
  - ordered boolean If true, only look for continuous numeric keys. (default false)
  - max number The maximum number of entries to find. (default nil)

  ### Returns:

  table or nil An ordered table with all the keys or `nil` if none were found.
gtable.find_first_key (t, matcher[, ordered=false])
  Find the first key that matches a function.
  - t table The table.
  - matcher function A function taking the key and value as arguments and returning a boolean.
  - ordered boolean If true, only look for continuous numeric keys. (default false)

  ### Returns:

  The table key or nil
keys (t)
  Get a sorted table with all integer keys from a table.
  - t table The table for which the keys to get.

  ### Returns:

  table A table with keys
keys_filter (t, ...)
  Filter a table's keys for certain content type.
  - t table The table to retrieve the keys for.
  - ... string The types to look for.

  ### Returns:

  table A filtered table.
reverse (t)
  Reverse a table.
  - t table The table to reverse.

  ### Returns:

  table A reversed table.
clone (t[, deep=true])
  Clone a table.
  - t table The table to clone.
  - deep bool Create a deep clone? (default true)

  ### Returns:

  table A clone of `t`.
iterate (t, filter, start)
  Iterate over a table. Returns an iterator to cycle through all elements of a table that match a given criteria, starting from the first element or the given index.
  - t table The table to iterate.
  - filter func A function that returns true to indicate a positive match.
  - start int Index to start iterating from. Default is 1 (=> start of the table). (default 1)

  ### Returns:

  func
merge (t, set)
  Merge items from one table to another one.
  - t table The container table
  - set table The mixin table.

  ### Returns:

  table (for convenience)
map (f, tbl)
  Map a function to a table. The function is applied to each value on the table, returning a modified table.
  - f function The function to be applied to each value in the table.
  - tbl table The container table whose values will be operated on.

  ### Returns:

  table

generated by LDoc 1.4.6 Last updated 2019-02-08 01:14:02