-
Notifications
You must be signed in to change notification settings - Fork 0
/
SortTest.cpp
65 lines (54 loc) · 1.24 KB
/
SortTest.cpp
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
#include "SortTest.h"
SortTest::SortTest(string name, SortFunction functionPointer, const int* data, int len):m_name(name)
{
m_name=name;
m_functionPointer=functionPointer;
m_originalData=data;
m_len=len;
m_time=0;
m_data=new int[m_len];
}
SortTest::~SortTest()
{
delete[] m_data;
return;
}
const int* SortTest::getData() const
{
return m_originalData;
}
int SortTest::getTime() const
{
int a=m_time;
return a;
}
string SortTest::getName() const
{
return m_name;
}
void SortTest::dataCopy()
{
for(int i=0; i<m_len; i++) m_data[i]=m_originalData[i];
}
void SortTest::run()
{
dataCopy();
int start=clock();
m_functionPointer(m_data, m_len);
m_time=clock()-start;
}
SortTest& SortTest::operator=(const SortTest& other)
{
if (this != &other)
{
this->m_name = other.m_name;
this->m_functionPointer = other.m_functionPointer;
this->m_originalData = other.m_originalData;
delete[] this->m_data;
this->m_data = new int[other.m_len];
memcpy(this->m_data, other.m_data, other.m_len);
this->m_len = other.m_len;
this->m_time = other.m_time;
}
return *this;
}