Appearance
OrderedTable
Inherits: LibTSMModule
Functions
ConcatKeys
lua
function BaseType.OrderedTable.ConcatKeys(tbl, sep)
-> stringConcatenate the keys into a string.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | |
sep | string | The separator string |
Returns:
| Type | Description |
|---|---|
string |
GetByIndex
lua
function BaseType.OrderedTable.GetByIndex(tbl, index)
-> <K>, <V>Gets a value from an ordered table by index.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | |
index | number |
Returns:
| Type | Description |
|---|---|
<K> | |
<V> |
Insert
lua
function BaseType.OrderedTable.Insert(tbl, key, value)Inserts into an ordered table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
key | K | The key to insert |
value | V | The value to insert |
InsertIfNotSet
lua
function BaseType.OrderedTable.InsertIfNotSet(tbl, key, value)Inserts into an ordered table if the key wasn't previously set.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
key | K | The key to insert |
value | V | The value to insert |
Iterator
lua
function BaseType.OrderedTable.Iterator(tbl)
-> fun():number, K, V, V[] & table<K, V>Iterates over an ordered table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
Returns:
| Type | Description |
|---|---|
fun():number, K, V | Iterator with fields: index, key, value |
V[] & table<K, V> |
KeyIterator
lua
function BaseType.OrderedTable.KeyIterator(tbl)
-> fun():number, K, V[] & table<K, V>Iterates over the keys of an ordered table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
Returns:
| Type | Description |
|---|---|
fun():number, K | Iterator with fields: key |
V[] & table<K, V> |
Remove
lua
function BaseType.OrderedTable.Remove(tbl, key)Removes from an ordered table.
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
key | K | The key to remove |
SortByKeys
lua
function BaseType.OrderedTable.SortByKeys(tbl)Sorts the ordered table by its keys
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |
SortByValues
lua
function BaseType.OrderedTable.SortByValues(tbl)Sorts the ordered table by its values
Parameters:
| Name | Type | Description |
|---|---|---|
tbl | OrderedTable.Table<K, V> | The ordered table |