2023-01-12 13:32:19 -06:00
|
|
|
#ifndef SORTS_H
|
|
|
|
#define SORTS_H
|
|
|
|
|
2023-02-11 19:22:37 -06:00
|
|
|
#include <chrono>
|
2023-01-12 13:32:19 -06:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2023-01-16 16:11:40 -06:00
|
|
|
enum SortType {INSERTION = 0, MERGE, HEAP};
|
|
|
|
|
2023-01-12 13:32:19 -06:00
|
|
|
class Sorter
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::string filename;
|
2023-01-16 16:11:40 -06:00
|
|
|
int lineCount;
|
|
|
|
std::vector<std::string> originalWordList;
|
2023-02-11 19:22:37 -06:00
|
|
|
std::chrono::duration<double> sortTime;
|
2023-02-11 22:43:54 -06:00
|
|
|
int heapSize; // Heap Sort only
|
2023-02-11 19:22:37 -06:00
|
|
|
public:
|
|
|
|
Sorter();
|
2023-01-16 16:11:40 -06:00
|
|
|
std::vector<std::string> newWordList;
|
2023-02-11 19:28:12 -06:00
|
|
|
bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven;
|
2023-01-16 16:11:40 -06:00
|
|
|
SortType currentType;
|
|
|
|
std::string GetFilename(void);
|
|
|
|
void SetFilename(std::string newName);
|
2023-01-12 13:32:19 -06:00
|
|
|
void SetWordList(void);
|
2023-02-11 19:22:37 -06:00
|
|
|
void SortAll(void);
|
2023-01-16 16:11:40 -06:00
|
|
|
void RunSorts(void);
|
2023-02-11 19:22:37 -06:00
|
|
|
void __RunSorts__(void);
|
2023-01-16 16:11:40 -06:00
|
|
|
void OutputResult(void);
|
2023-02-11 19:22:37 -06:00
|
|
|
void PrintSortTime(std::string outputFilename);
|
2023-01-16 16:11:40 -06:00
|
|
|
void PrintToFile(std::string outputFilename);
|
2023-01-12 13:32:19 -06:00
|
|
|
void InsertionSort(void);
|
|
|
|
void MergeSort(void);
|
2023-01-19 13:04:06 -06:00
|
|
|
void __MergeSort__(int p, int r);
|
|
|
|
void __Merge__(int p, int q, int r);
|
2023-01-12 13:32:19 -06:00
|
|
|
void HeapSort(void);
|
2023-02-11 22:43:54 -06:00
|
|
|
void __HeapSort__(void);
|
|
|
|
void __Heapify__(int i);
|
|
|
|
int __LEFT__(int i);
|
|
|
|
int __RIGHT__(int i);
|
2023-01-12 13:32:19 -06:00
|
|
|
};
|
|
|
|
|
2023-02-11 19:22:37 -06:00
|
|
|
void CheckArguments(int argc, char* arguments[], Sorter* sortObj);
|
|
|
|
|
2023-01-16 16:11:40 -06:00
|
|
|
#endif
|