Changed function order for readability
This commit is contained in:
		
							parent
							
								
									0fbc5b8bea
								
							
						
					
					
						commit
						f3de22da46
					
				@ -19,6 +19,48 @@ SortController::SortController()
 | 
				
			|||||||
    sortGiven = 0;
 | 
					    sortGiven = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Checks for command line arguments
 | 
				
			||||||
 | 
					void SortController::CheckArguments(int argc, char* arguments[])
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    std::string tempStr;
 | 
				
			||||||
 | 
					    for (int i = 0; i < argc; i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        tempStr = arguments[i];
 | 
				
			||||||
 | 
					        if ((tempStr == "-a") || (tempStr == "--all"))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            defaultOnly = 0;
 | 
				
			||||||
 | 
					            allLists = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if ((tempStr == "-f") || (tempStr == "--filename"))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            filename = arguments[i + 1];
 | 
				
			||||||
 | 
					            defaultOnly = 0;
 | 
				
			||||||
 | 
					            fileGiven = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if ((tempStr == "-d") || (tempStr == "--default"))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            filename = "test/PERM/perm15K.txt";
 | 
				
			||||||
 | 
					            defaultFile = 1;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        if ((tempStr == "-s") || (tempStr == "--sort-type"))
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            sortGiven = 1;
 | 
				
			||||||
 | 
					            tempStr = arguments[i + 1];
 | 
				
			||||||
 | 
					            if (tempStr == "insertion")
 | 
				
			||||||
 | 
					                currentType = INSERTION;
 | 
				
			||||||
 | 
					            if (tempStr == "merge")
 | 
				
			||||||
 | 
					                currentType = MERGE;
 | 
				
			||||||
 | 
					            if (tempStr == "heap")
 | 
				
			||||||
 | 
					                currentType = HEAP;
 | 
				
			||||||
 | 
					            if (tempStr == "all")
 | 
				
			||||||
 | 
					                sortGiven = 0;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    if (defaultOnly)
 | 
				
			||||||
 | 
					        filename = "test/PERM/perm15K.txt";
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sets word list found in file into vector 
 | 
					// Sets word list found in file into vector 
 | 
				
			||||||
void SortController::ReadWordFile(void)
 | 
					void SortController::ReadWordFile(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -50,23 +92,6 @@ void SortController::RunBenchmarks(void)
 | 
				
			|||||||
    return;
 | 
					    return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Sorts all default files if allLists is set
 | 
					 | 
				
			||||||
void SortController::BenchmarkingAll(void)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    int fileCount = 10;
 | 
					 | 
				
			||||||
    std::string newFilename;
 | 
					 | 
				
			||||||
    for (int i = 1; i <= fileCount; i++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        lineCount = 0;
 | 
					 | 
				
			||||||
        newFilename = "test/PERM/perm";
 | 
					 | 
				
			||||||
        newFilename += std::to_string(15*i);
 | 
					 | 
				
			||||||
        newFilename += "K.txt";
 | 
					 | 
				
			||||||
        filename = newFilename;
 | 
					 | 
				
			||||||
        ReadWordFile();
 | 
					 | 
				
			||||||
        Benchmarking();
 | 
					 | 
				
			||||||
        originalWordList.clear();
 | 
					 | 
				
			||||||
    } 
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Function for starting sort functions
 | 
					// Function for starting sort functions
 | 
				
			||||||
void SortController::Benchmarking(void)
 | 
					void SortController::Benchmarking(void)
 | 
				
			||||||
@ -106,6 +131,25 @@ void SortController::Benchmarking(void)
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Sorts all default files if allLists is set
 | 
				
			||||||
 | 
					void SortController::BenchmarkingAll(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int fileCount = 10;
 | 
				
			||||||
 | 
					    std::string newFilename;
 | 
				
			||||||
 | 
					    for (int i = 1; i <= fileCount; i++)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        lineCount = 0;
 | 
				
			||||||
 | 
					        newFilename = "test/PERM/perm";
 | 
				
			||||||
 | 
					        newFilename += std::to_string(15*i);
 | 
				
			||||||
 | 
					        newFilename += "K.txt";
 | 
				
			||||||
 | 
					        filename = newFilename;
 | 
				
			||||||
 | 
					        ReadWordFile();
 | 
				
			||||||
 | 
					        Benchmarking();
 | 
				
			||||||
 | 
					        originalWordList.clear();
 | 
				
			||||||
 | 
					    } 
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Main function for printing results
 | 
					// Main function for printing results
 | 
				
			||||||
void SortController::OutputResult(void)
 | 
					void SortController::OutputResult(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -153,45 +197,3 @@ void SortController::WriteOutputToFile(std::string outputFilename)
 | 
				
			|||||||
        file << newWordList[i] << '\n';
 | 
					        file << newWordList[i] << '\n';
 | 
				
			||||||
    file.close();
 | 
					    file.close();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// Checks for command line arguments
 | 
					 | 
				
			||||||
void SortController::CheckArguments(int argc, char* arguments[])
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    std::string tempStr;
 | 
					 | 
				
			||||||
    for (int i = 0; i < argc; i++)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        tempStr = arguments[i];
 | 
					 | 
				
			||||||
        if ((tempStr == "-a") || (tempStr == "--all"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            defaultOnly = 0;
 | 
					 | 
				
			||||||
            allLists = 1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ((tempStr == "-f") || (tempStr == "--filename"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            filename = arguments[i + 1];
 | 
					 | 
				
			||||||
            defaultOnly = 0;
 | 
					 | 
				
			||||||
            fileGiven = 1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ((tempStr == "-d") || (tempStr == "--default"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            filename = "test/PERM/perm15K.txt";
 | 
					 | 
				
			||||||
            defaultFile = 1;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        if ((tempStr == "-s") || (tempStr == "--sort-type"))
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            sortGiven = 1;
 | 
					 | 
				
			||||||
            tempStr = arguments[i + 1];
 | 
					 | 
				
			||||||
            if (tempStr == "insertion")
 | 
					 | 
				
			||||||
                currentType = INSERTION;
 | 
					 | 
				
			||||||
            if (tempStr == "merge")
 | 
					 | 
				
			||||||
                currentType = MERGE;
 | 
					 | 
				
			||||||
            if (tempStr == "heap")
 | 
					 | 
				
			||||||
                currentType = HEAP;
 | 
					 | 
				
			||||||
            if (tempStr == "all")
 | 
					 | 
				
			||||||
                sortGiven = 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    if (defaultOnly)
 | 
					 | 
				
			||||||
        filename = "test/PERM/perm15K.txt";
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user