#include "Sort.h"
Sort::Sort()
{
this->setSize(0);
this->swapNum = 0;
this->memEval = 0;
}
Sort::Sort(int n, int* x)
{
this->setArr(x);
this->setSize(n);
this->swapNum = 0;
this->memEval = 0;
this->countSwaps = true;
this->algName = "Default Sort";
}
void Sort::Run(void) {
}
int* Sort::getArr(void) {
return this->x;
}
void Sort::setArr(int* x) {
this->swapNum = 0;
this->x = x;
}
int Sort::getSize(void) {
return this->n;
}
void Sort::setSize(int n) {
this->n = n;
}
char* Sort::getName(void) {
return this->algName;
}
int Sort::getSwapNum(void) {
return this->swapNum;
}
void Sort::DisableSwapCount() {
this->countSwaps = false;
}
void Sort::CountSwap() {
if (this->countSwaps) {
this->swapNum++;
}
}
void Sort::Print(void) {
for (int i = 0; i < this->n; i++) {
cout << this->x
[i
] <<
' ';
}
}
void Sort::RandomFill(int left = 0, int right = 100) {
srand( (unsigned)time(NULL));
for (int i = 0; i < this->n; i++) {
this->x[i] = left + rand() % (right - left);
}
}
void Sort::Swap(int i, int j) {
int tmp;
tmp = this->x[i]; this->x[i] = this->x[j]; this->x[j] = tmp;
this->CountSwap();
}
void Sort::CopyTo(int* dest) {
for (int i = 0; i < this->n; i++) {
dest[i] = this->x[i];
}
}
void Sort::Print2(int* arr, int n) {
for (int i = 0; i < n; i++) {
}
}
Sort::~Sort(void)
{
delete [] x;
}