noffie
a89b27d456
* init rework * Update LICENSE * removing tests * adding Gui Component system * added spdlog library * Fixed input restriction bug * nothing * Making the default button stand out * Setting up run Component * changing components * restarted because i cant do it visualising sorting through value/step diagrams * g * working (kinda) * fixed sqrt comp error * added debug flag * abbandoning Lua... Error in runtime * fixing errors, making cuts * removing unnessecary dependencies * Improving UI
25 lines
No EOL
488 B
Lua
25 lines
No EOL
488 B
Lua
|
|
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 |