-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cc
77 lines (71 loc) · 1.43 KB
/
test.cc
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
71
72
73
74
75
76
77
#include"scy_test.h"
#include"mergesort.h"
#include"Insertsort.h"
#include<iostream>
#include<algorithm>
using namespace std;
using namespace scy_test;
int main(int argc, const char *argv[])
{
const int NUM = 10;
vector<RandomArray<int> > randvec(NUM);
{
timer t("mergesort");
for(int i = 0; i < NUM; ++i)
{
vector<int> iv = randvec[i].getUnsortedArray();
mergesort(iv, 0, iv.size()-1);
IsSorted(iv);
}
/*
RandomArray<int> arr(40,1000);
auto iv = arr.getUnsortedArray();
mergesort(iv, 0, iv.size()-1);
IsSorted(iv);
*/
}
{
timer t("std::sort");
for(int i = 0; i < NUM; ++i)
{
vector<int> iv = randvec[i].getUnsortedArray();
sort(iv.begin(),iv.end());
IsSorted(iv);
}
}
{
timer t("std::stable_sort");
for(int i = 0; i < NUM; ++i)
{
vector<int> iv = randvec[i].getUnsortedArray();
stable_sort(iv.begin(),iv.end());
IsSorted(iv);
}
}
{
timer t("insertsort");
//RandomArray<int> arr(40,1000);
for(int i = 0; i < NUM; ++i)
{
vector<int> iv = randvec[i].getUnsortedArray();
Insertsort(iv, iv.size());
IsSorted(iv);
}
}
{
timer t("insertsort recursious");
for(int i = 0; i < NUM; ++i)
{
vector<int> iv = randvec[i].getUnsortedArray();
InsertsortR(iv, iv.size() - 1, iv.size());
IsSorted(iv);
}
/*
RandomArray<int> arr(40,1000);
auto iv = arr.getUnsortedArray();
InsertsortR(iv, iv.size() - 1, iv.size());
IsSorted(iv);
*/
}
return 0;
}