updated naming
This commit is contained in:
@@ -2,52 +2,48 @@
|
||||
#include "timer.hpp"
|
||||
#include "timeractions.hpp"
|
||||
#include <algorithm>
|
||||
#include <chrono>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <ncurses.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
swapaction::swapaction(std::vector<int> &input_vector): input_vector(input_vector){}
|
||||
SwapAction::SwapAction(std::vector<int> &input_vector): input_vector(input_vector){}
|
||||
|
||||
void swapaction::update(const timer &input_timer){
|
||||
if (!iscomplete) {
|
||||
void SwapAction::update(const Timer &input_timer){
|
||||
if (!is_complete) {
|
||||
int temp = input_vector[it_i];
|
||||
input_vector[it_i] = input_vector[input_vector.size() -1 - it_i];
|
||||
input_vector[input_vector.size() - 1 - it_i] = temp;
|
||||
it_i++;
|
||||
if(it_i>=input_vector.size() / 2){iscomplete=true;}
|
||||
if(it_i>=input_vector.size() / 2){is_complete=true;}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sortaction::sortaction(std::vector<int> &input_vector): input_vector(input_vector) {}
|
||||
SortAction::SortAction(std::vector<int> &input_vector): input_vector(input_vector) {}
|
||||
|
||||
//sorts the included array using bsort and external iterators rather than for loops
|
||||
void sortaction::update(const timer &input_timer) {
|
||||
if (!iscomplete) {
|
||||
void SortAction::update(const Timer &input_timer) {
|
||||
if (!is_complete) {
|
||||
/**
|
||||
we take a number, it_i loop
|
||||
compare it with its neighbour, it_j loop
|
||||
if it's larger swap it
|
||||
keep going until it_i == length - sorted numbers
|
||||
once that is true, reset it_j and advance it_i
|
||||
once that is true, reset it_j and advance it_i
|
||||
**/
|
||||
if (input_vector[it_j]>input_vector[it_j+1]) {
|
||||
// int temp = input_vector[it_j + 1];
|
||||
// input_vector[it_j + 1] = input_vector[it_j];
|
||||
// input_vector[it_j] = temp;
|
||||
std::swap(input_vector[it_j], input_vector[it_j+1]);
|
||||
}
|
||||
std::swap(input_vector[it_j], input_vector[it_j+1]);
|
||||
}
|
||||
it_j++;
|
||||
|
||||
|
||||
if (it_j >= input_vector.size() - 1 - it_i) {
|
||||
it_j = 0;
|
||||
it_i++;
|
||||
}
|
||||
}
|
||||
if (it_i>=input_vector.size()) {
|
||||
iscomplete=true;
|
||||
}
|
||||
is_complete=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user