aboutsummaryrefslogtreecommitdiff
path: root/library/lullaby/table.lua
blob: b5ee919cacf7e57e9c737a6106d13b2162fc984d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---@meta

---to be mostly rewritten
---@class lullaby.table
local table = {}

---splits string into smaller strings, removing the delimiter
---```lua
---llby.table.split("/hello/world//test///", "/") -- {"hello", "world", "test"}
---llby.table.split("/hello/world//test///", "/", false) -- {"hello", "world", "", "test", "", "", ""}
---```
---@param haystack string
---@param search string
---@param skip boolean? whether or not to skip empty chunks
---@return string[]
function table.split(haystack, search, skip) end

---returns the index that N is located at, or nil
---@param t any[]
---@param N any
---@return any
function table.contains(t, N) end

---compares 2 tables recursivley
---@param A any[]
---@param B any[]
---@param depth integer? max depth to search, defaults to -1
---@return boolean
function table.equal(A, B, depth) end

---clones table recursivley
---@param table any[]
---@return value[]
function table.dup(table) end

---gets table len, useful for key,value tables
---@param table any[]
---@return integer
function table.len(table) end

---greatest, least
---@param array number[]
---@return number[]
function table.quicksort(array) end

---greatest, least
---@param array number[]
---@return number[]
function table.mergesort(array) end

---greatest, least
---@param array number[]
---@return number[]
function table.shellsort(array) end

---greatest, least
---@param array number[]
---@return number[]
function table.bubblesort(array) end

---greatest, least
---@param array number[]
---@return number[]
function table.heapsort(array) end

return table