switched from raw lambda to stepable
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
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user