6f7bd9d964
couldn't figure out how to handle sortstate, eventually put it into bsort class. should be split into timeraction and steppable. and there shouldn't be a random steppedbsort in App
30 lines
459 B
C++
30 lines
459 B
C++
#include <cstdio>
|
|
#include <utility>
|
|
#include "sorters.hpp"
|
|
using namespace std;
|
|
|
|
|
|
SteppedBsort::SteppedBsort(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;
|
|
}
|