abbandoning Lua... Error in runtime
This commit is contained in:
parent
cafced2917
commit
54703852e7
20 changed files with 1119 additions and 164 deletions
25
res/lua/bubble_sortiva.lua
Normal file
25
res/lua/bubble_sortiva.lua
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
local bubble_sort = Future:new()
|
||||
|
||||
function bubble_sort:poll(array)
|
||||
local n = array:size()
|
||||
self.state[n] = self.state[n] or n
|
||||
if n == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
local swapped = false
|
||||
for i = 1, n - 1 do
|
||||
if array.at(i-1) > array.at(i) then
|
||||
array.swap(i-1, i)
|
||||
swapped = true
|
||||
end
|
||||
end
|
||||
self.state.n = self.state.n - 1
|
||||
|
||||
return not swapped
|
||||
end
|
||||
|
||||
function make_available(sorter_list)
|
||||
table.insert(sorter_list, "bubble_sort")
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue