-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
70 lines (55 loc) · 2.12 KB
/
Copy pathmain.cpp
File metadata and controls
70 lines (55 loc) · 2.12 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "OO_Comparison.h"
#include "Template_Comparison.h"
const char alphanum[] = "abcdefghijklmnopqrstuvwxyz";
int main() {
//OO Comparison
sortingFunctions f; // I just didn't want to include all those functions in this file
vector<IComparable*> intVector(vectorSize);
vector<IComparable*> stringVector(vectorSize);
for (int x = 0; x < vectorSize; x++) {
IntWrapper *newInt = new IntWrapper(rand() % 1001);
intVector[x] = newInt;
string str;
for (int y = 0; y < stringSize; y++) {
str+=alphanum[rand()%26];
}
StringWrapper *newString = new StringWrapper(str);
stringVector[x] = newString;
}
cout << "UNSORTED INTVECTOR" << endl;
f.print(intVector);
cout << "SORTED INTVECTOR" << endl;
intVector = f.sorting(intVector);
f.print(intVector);
cout << "UNSORTED STRINGVECTOR" << endl;
f.print(stringVector);
cout << "SORTED STRINGVECTOR" << endl;
stringVector = f.sorting(stringVector);
f.print(stringVector);
cout << "TEMPLATE COMPARISONS" << endl;
//Template Comparison
templateSort<int> intSort;
vector<Comparable<int> *> intTemplateVector(vectorSize);
templateSort<string> stringSort;
vector<Comparable<string> *> stringTemplateVector(vectorSize);
for (int x = 0; x < vectorSize; x++) {
Comparable<int> *newInt = new Comparable<int>(rand() % 1001);
intTemplateVector[x] = newInt;
string str;
for (int y = 0; y < stringSize; y++) {
str+=alphanum[rand()%26];
}
Comparable<string> *newString = new Comparable<string>(str);
stringTemplateVector[x] = newString;
}
cout << "UNSORTED INTVECTOR" << endl;
intSort.print(intTemplateVector);
cout << "SORTED INTVECTOR" << endl;
intTemplateVector = intSort.tSort(intTemplateVector);
intSort.print(intTemplateVector);
cout << "UNSORTED STRINGVECTOR" << endl;
stringSort.print(stringTemplateVector);
cout << "SORTED STRINGVECTOR" << endl;
stringTemplateVector = stringSort.tSort(stringTemplateVector);
stringSort.print(stringTemplateVector);
}