Files
sortui/src/sorters.cpp
T
lyrgb 6e71aeebb4 app now just coordinates the components initialized in main
reduced responsibilities of constructors
started using more pointers.
sessions through app rather than app itself.
mostly split view away from app (still hard coded)
haven't decoupled sorts from timers as their actuator yet
2026-08-15 03:14:54 +02:00

31 lines
493 B
C++

#include <cstdio>
#include <memory>
#include <utility>
#include "sorters.hpp"
using namespace std;
SteppedBsort::SteppedBsort(shared_ptr<SortInput> input): data(input) {};
bool SteppedBsort:: step(){
if(is_finished==true) {
printf("finished");
return true;
}
if(data->values[j]>data->values[j+1])
{
swap(data->values[j], data->values[j+1]);
}
j++;
if(j>=data->values.size()-1 -i){
j=0;
i++;
}
if (i==data->values.size()-1){
is_finished=true;
}
return false;
}