## utils.table module

Searches a table to remove a specific element without an index

### Dependencies

utils.inspect

### Functions

fast_remove(tbl, index) | Removes an item from an array in O(1) time.
add_all(t1, t2) | Adds the contents of table t2 to table t1
index_of(t, e) | Checks if a table contains an element
index_of_in_array(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
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
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
clear_table(t, array) | Clears all existing entries in a table

### 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

# utils.inspect

### Functions

# fast_remove(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.
# add_all(t1, t2)

  Adds the contents of table t2 to table t1

  Parameters:
  - t1 :

    to insert into

  - t2 :

    to insert from

# index_of(t, e)

  Checks if a table contains an element

  Parameters:
  - t :

  - e : table element
  Returns:
  - the index of the element or nil
# index_of_in_array(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
# 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
# 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
# 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

### 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 :