## overrides.table module

Searches a table to remove a specific element without an index

### Dependencies

overrides.inspect

### Functions

remove_index(tbl, index) | Removes an item from an array in O(1) time.
merge_table(t1, t2) | Adds the contents of table t2 to table t1
array_insert(tbl[, start_index], values) | Much faster method for inserting items into an array
table_insert(tbl[, start_index], tbl2) | Much faster method for inserting keys into a table
get_key(t, e) | Checks if a table contains an element
get_index(t, e) | Checks if the arrayed portion of a table contains an element
contains(t, e) | Checks if a table contains an element
array_contains(t, e) | Checks if the arrayed portion of a table contains an element
extract_keys(tbl, ...) | Extracts certain keys from a table
set(t, index, element) | Adds an element into a specific index position while shuffling the rest down
get_random_dictionary_entry(t, key) | Chooses a random entry from a table because this uses math.random, it cannot be used outside of events
get_random_weighted(weighted_table, item_index, weight_index) | Chooses a random entry from a weighted table because this uses math.random, it cannot be used outside of events
clear_table(t, array) | Clears all existing entries in a table
shuffle_table(t, rng) | Creates a fisher-yates shuffle of a sequential number-indexed table because this uses math.random, it cannot be used outside of events if no rng is supplied from: http://www.sdknews.com/cross-platform/corona/tutorial-how-to-shuffle-table-items
get_values(tbl[, sorted][, as_string]) | Returns a copy of all of the values in the table.
get_keys(tbl[, sorted][, as_string]) | Returns a copy of all of the keys in the table.
alphanumsort(tbl) | Returns the list is a sorted way that would be expected by people (this is by key)
keysort(tbl) | Returns the list is a sorted way that would be expected by people (this is by key) (faster alternative than above)

### Fields

inspect | Similar to serpent.block, returns a string with a pretty representation of a table.
size | Takes a table and returns the number of entries in the table.
deep_copy | Creates a deepcopy of a table.
merge | Merges multiple tables.
equals | Determines if two tables are structurally equal.

### Dependencies

# overrides.inspect

### Functions

# remove_index(tbl, index)

  Removes an item from an array in O(1) time.

  The catch is that fast_remove doesn't guarantee to maintain the order of items in the array.

  Parameters:
  - tbl :

    arrayed table

  - index : Must be >= 0. The case where index > #tbl is handled.
# merge_table(t1, t2)

  Adds the contents of table t2 to table t1

  Parameters:
  - t1 :

    to insert into

  - t2 :

    to insert from

# array_insert(tbl[, start_index], values)

  Much faster method for inserting items into an array

  Parameters:
  - tbl : (table) the table that will have the values added to it
  - start_index : (number) the index at which values will be added, nil means end of the array (optional)
  - values : (table) the new values that will be added to the table
  Returns:
  - (table) the table that was passed as the first argument
  Usage:

      -- Adding 1000 values into the middle of the array
      local tbl = {}
      local values = {}
      for i = 1, 1000 do tbl[i] = i values[i] = i end
      table.array_insert(tbl, 500, values) -- around 0.4ms

# table_insert(tbl[, start_index], tbl2)

  Much faster method for inserting keys into a table

  Parameters:
  - tbl : (table) the table that will have keys added to it
  - start_index : (number) the index at which values will be added, nil means end of the array, numbered indexs only (optional)
  - tbl2 : (table) the table that may contain both string and numbered keys
  Returns:
  - (table) the table passed as the first argument
  Usage:

      -- Merging two tables
      local tbl = {}
      local tbl2 = {}
      for i = 1, 100 do tbl[i] = i tbl['_'..i] = i tbl2[i] = i tbl2['__'..i] = i end
      table.table_insert(tbl, 50, tbl2)

# get_key(t, e)

  Checks if a table contains an element

  Parameters:
  - t :

  - e : table element
  Returns:
  - the index of the element or nil
# get_index(t, e)

  Checks if the arrayed portion of a table contains an element

  Parameters:
  - t :

  - e : table element
  Returns:
  - the index of the element or nil
# contains(t, e)

  Checks if a table contains an element

  Parameters:
  - t :

  - e : table element
  Returns:
  - indicating success
# array_contains(t, e)

  Checks if the arrayed portion of a table contains an element

  Parameters:
  - t :

  - e : table element
  Returns:
  - indicating success
# extract_keys(tbl, ...)

  Extracts certain keys from a table

  Parameters:
  - tbl : (table) table the which contains the keys
  - ... : (string) the names of the keys you want extracted
  Returns:
  - the keys in the order given
  Usage:

      local key_three, key_one = extract({key_one='foo', key_two='bar', key_three=true}, 'key_three', 'key_one')

# set(t, index, element)

  Adds an element into a specific index position while shuffling the rest down

  Parameters:
  - t :

    to add into

  - index : the position in the table to add to
  - element : to add to the table
# get_random_dictionary_entry(t, key)

  Chooses a random entry from a table because this uses math.random, it cannot be used outside of events

  Parameters:
  - t :

  - key : to indicate whether to return the key or value
  Returns:
  - a random element of table t
# get_random_weighted(weighted_table, item_index, weight_index)

  Chooses a random entry from a weighted table because this uses math.random, it cannot be used outside of events

  Parameters:
  - weighted_table :

    of tables with items and their weights

  - item_index : of the index of items, defaults to 1
  - weight_index : of the index of the weights, defaults to 2
  Returns:
  - table element
# clear_table(t, array)

  Clears all existing entries in a table

  Parameters:
  - t :

    to clear

  - array : to indicate whether the table is an array or not
# shuffle_table(t, rng)

  Creates a fisher-yates shuffle of a sequential number-indexed table because this uses math.random, it cannot be used outside of events if no rng is supplied from: http://www.sdknews.com/cross-platform/corona/tutorial-how-to-shuffle-table-items

  Parameters:
  - t :

    to shuffle

  - rng : to provide random numbers
# get_values(tbl[, sorted][, as_string])

  Returns a copy of all of the values in the table.

  Parameters:
  - tbl : (table) the to copy the keys from, or an empty table if tbl is nil
  - sorted : (boolean) whether to sort the keys (slower) or keep the random order from pairs() (optional)
  - as_string : (boolean) whether to try and parse the values as strings, or leave them as their existing type (optional)
  Returns:
  - (array) an array with a copy of all the values in the table
# get_keys(tbl[, sorted][, as_string])

  Returns a copy of all of the keys in the table.

  Parameters:
  - tbl : (table) the to copy the keys from, or an empty table if tbl is nil
  - sorted : (boolean) whether to sort the keys (slower) or keep the random order from pairs() (optional)
  - as_string : (boolean) whether to try and parse the keys as strings, or leave them as their existing type (optional)
  Returns:
  - (array) an array with a copy of all the keys in the table
# alphanumsort(tbl)

  Returns the list is a sorted way that would be expected by people (this is by key)

  Parameters:
  - tbl : (table) the table to be sorted
  Returns:
  - (table) the sorted table
# keysort(tbl)

  Returns the list is a sorted way that would be expected by people (this is by key) (faster alternative than above)

  Parameters:
  - tbl : (table) the table to be sorted
  Returns:
  - (table) the sorted table

### Fields

# inspect

  Similar to serpent.block, returns a string with a pretty representation of a table.

  Notice: This method is not appropriate for saving/restoring tables. It is meant to be used by the programmer mainly while debugging a program. depth sets the maximum depth that will be printed out. When the max depth is reached, inspect will stop parsing tables and just return {...} process is a function which allow altering the passed object before transforming it into a string. A typical way to use it would be to remove certain values so that they don't appear at all. return the prettied table

  - table :

    the table to serialize

  - options :

    options are depth, newline, indent, process

# size

  Takes a table and returns the number of entries in the table.

  (Slower than #table, faster than iterating via pairs)

# deep_copy

  Creates a deepcopy of a table.

  Metatables and LuaObjects inside the table are shallow copies. Shallow copies meaning it copies the reference to the object instead of the object itself.

  - object :

    the object to copy

# merge

  Merges multiple tables.

  Tables later in the list will overwrite entries from tables earlier in the list. Ex. merge({{1, 2, 3}, {[2] = 0}, {[3] = 0}}) will return {1, 0, 0}

  - tables :

    takes a table of tables to merge

# equals

  Determines if two tables are structurally equal.

  Notice: tables that are LuaObjects or contain LuaObjects won't be compared correctly, use == operator for LuaObjects

  - tbl1 :

  - tbl2 :