sorting-algorithms/include/sorts.h

54 lines
1.6 KiB
C++

#ifndef SORTS_H
#define SORTS_H
#include <chrono>
#include <string>
#include <vector>
enum SortType {INSERTION = 0, MERGE, HEAP};
class Sorter
{
private:
std::string filename;
int lineCount;
std::vector<std::string> originalWordList;
std::chrono::duration<double> sortTime;
public:
Sorter();
std::vector<std::string> newWordList;
bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven;
SortType currentType;
std::string GetFilename(void);
void SetFilename(std::string newName);
void SetWordList(void);
void SortAll(void);
void RunSorts(void);
void __RunSorts__(void);
void OutputResult(void);
void PrintSortTime(std::string outputFilename);
void PrintToFile(std::string outputFilename);
};
void CheckArguments(int argc, char* arguments[], Sorter* sortObj);
namespace ImplementedSort
{
// Performs Insertion Sort on given word list (vector of strings)
void InsertionSort(std::vector<std::string> *newWordList);
// Performs Merge Sort on given word list (vector of strings)
void MergeSort(std::vector<std::string> *newWordList);
void __MergeSort__(std::vector<std::string> *newWordList, int p, int r);
void __Merge__(std::vector<std::string> *newWordList, int p, int q, int r);
// Performs Heap Sort on given word list (vector of strings)
void HeapSort(std::vector<std::string> *newWordList);
void __HeapSort__(std::vector<std::string> *newWordList);
void __Heapify__(std::vector<std::string> *newWordList, int i, int heapSize);
int __HEAPSORT_LEFT__(int i);
int __HEAPSORT_RIGHT__(int i);
}
#endif