Setup getting filename and inputting list
This commit is contained in:
parent
39eb906721
commit
7e8873fd1a
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1,3 @@
|
|||||||
wordlists
|
wordlists
|
||||||
|
bin/*.out
|
||||||
|
build/*.o
|
||||||
|
5
Makefile
5
Makefile
@ -1,7 +1,10 @@
|
|||||||
|
INC := -I include
|
||||||
|
|
||||||
main: compile link
|
main: compile link
|
||||||
|
|
||||||
compile:
|
compile:
|
||||||
g++ -c -o build/main.o src/main.cpp
|
g++ $(INC) -c -o build/main.o src/main.cpp
|
||||||
|
g++ $(INC) -c -o build/sorts.o src/sorts.cpp
|
||||||
|
|
||||||
link:
|
link:
|
||||||
g++ -o bin/main.out build/*.o
|
g++ -o bin/main.out build/*.o
|
||||||
|
BIN
bin/main.out
BIN
bin/main.out
Binary file not shown.
BIN
build/main.o
BIN
build/main.o
Binary file not shown.
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef SORTS_H
|
||||||
|
#define SORTS_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class Sorter
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
std::string filename;
|
||||||
|
std::vector<std::string> wordList;
|
||||||
|
public:
|
||||||
|
void SetFileName(std::string newName);
|
||||||
|
std::string GetFileName(void);
|
||||||
|
void SetWordList(void);
|
||||||
|
void InsertionSort(void);
|
||||||
|
void MergeSort(void);
|
||||||
|
void HeapSort(void);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -1,7 +1,9 @@
|
|||||||
#include <iostream>
|
#include "sorts.h"
|
||||||
|
|
||||||
int main(void)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
std::cout << "hello world\n";
|
Sorter newSort;
|
||||||
|
newSort.SetFileName(argv[1]);
|
||||||
|
newSort.SetWordList();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
#include "sorts.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void Sorter::SetFileName(std::string newName)
|
||||||
|
{
|
||||||
|
this->filename = newName;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Sorter::GetFileName(void)
|
||||||
|
{
|
||||||
|
return this->filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sorter::SetWordList(void)
|
||||||
|
{
|
||||||
|
std::string bufferStr;
|
||||||
|
std::ifstream file(this->filename);
|
||||||
|
if (!file.is_open())
|
||||||
|
{
|
||||||
|
std::cout << "Failed opening file\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
while (getline(file, bufferStr))
|
||||||
|
wordList.push_back(bufferStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sorter::InsertionSort(void)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sorter::MergeSort(void)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sorter::HeapSort(void)
|
||||||
|
{
|
||||||
|
;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user