Major refactor of files
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
#ifndef BASIC_SORTS_HPP
|
||||
#define BASIC_SORTS_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Different basic sorting algorithm implementations
|
||||
namespace basic_sorts
|
||||
{
|
||||
// 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
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef SORT_CONTROLLER_HPP
|
||||
#define SORT_CONTROLLER_HPP
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
enum SortType {INSERTION = 0, MERGE, HEAP};
|
||||
|
||||
class SortController
|
||||
{
|
||||
public:
|
||||
SortController();
|
||||
void CheckArguments(int argc, char* arguments[]);
|
||||
void ReadWordFile(void);
|
||||
void RunBenchmarks(void);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
std::string filename;
|
||||
SortType currentType;
|
||||
std::chrono::duration<double> sortTime;
|
||||
std::vector<std::string> newWordList;
|
||||
std::vector<std::string> originalWordList;
|
||||
int lineCount;
|
||||
bool defaultFile, defaultOnly, fileGiven, allLists, sortGiven;
|
||||
void Benchmarking(void);
|
||||
void BenchmarkingAll(void);
|
||||
void OutputResult(void);
|
||||
void EchoSortTime(std::string outputFilename);
|
||||
void WriteOutputToFile(std::string outputFilename);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,53 +0,0 @@
|
||||
#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
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef TREES_HPP
|
||||
#define TREES_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
// Namespace for different implementations of trees
|
||||
namespace tree_implementation
|
||||
{
|
||||
// Base Tree class
|
||||
class Tree
|
||||
{
|
||||
public:
|
||||
Tree(void);
|
||||
void Insert(void);
|
||||
void Search(void);
|
||||
void InOrderTreeTraversal(void);
|
||||
protected:
|
||||
virtual void PrintParentKey(std::string key) = 0;
|
||||
virtual void PrintLeftChild(std::string key) = 0;
|
||||
virtual void PrintRightChild(std::string key) = 0;
|
||||
virtual void PrintPathToRoot(std::string key) = 0;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
// Binary Search Tree operations
|
||||
// TODO: Implement BST
|
||||
class BinarySearchTree : public Tree
|
||||
{
|
||||
public:
|
||||
void PrintParentKey(std::string key);
|
||||
void PrintLeftChild(std::string key);
|
||||
void PrintRightChild(std::string key);
|
||||
void PrintPathToRoot(std::string key);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
;
|
||||
};
|
||||
|
||||
// Red-Black Tree operations
|
||||
// TODO: Implement Red-black tree
|
||||
class RedBlackTree : public Tree
|
||||
{
|
||||
public:
|
||||
void PrintParentKey(std::string key);
|
||||
void PrintLeftChild(std::string key);
|
||||
void PrintRightChild(std::string key);
|
||||
void PrintPathToRoot(std::string key);
|
||||
void PrintColor(std::string key);
|
||||
void PrintParentColor(std::string key);
|
||||
void PrintUncleColor(std::string key);
|
||||
protected:
|
||||
;
|
||||
private:
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user