-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsorter.hpp
52 lines (46 loc) · 1.22 KB
/
sorter.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @file
* @author The CS2 TA Team
* @version 1.0
* @date 2013-2014
* @copyright This code is in the public domain.
*
* @brief The bubble sort, quick sort, merge sort, and in-place quicksort
* algorithms (header file).
*
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include "fileio.hpp"
#ifndef BUBBLE_SORT
#define BUBBLE_SORT 0
#endif
#ifndef QUICK_SORT
#define QUICK_SORT 1
#endif
#ifndef MERGE_SORT
#define MERGE_SORT 2
#endif
#ifndef QUICK_SORT_INPLACE
#define QUICK_SORT_INPLACE 3
#endif
std::vector<int> bubbleSort(std::vector<int> &list);
std::vector<int> quickSort(std::vector<int> &list);
void quicksort_inplace(std::vector<int> &list, int left, int right);
std::vector<int> mergeSort(std::vector<int> &list);
std::vector<int> merge(std::vector<int> &left, std::vector<int> &right);
void usage();
const char *usage_string =
"Usage: sorter [-b] [-m] [-q] [-qi] FILE\n\
Sorts a file that contains integers delimited by newlines and prints the \
result to stdout.\n\
-b bubble sort\n\
-m merge sort\n\
-q quick sort\n\
-qi in-place quick sort\n\
No option defaults to bubble sort.\n";