-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathalgorithm_interface.h
More file actions
57 lines (47 loc) · 1.03 KB
/
algorithm_interface.h
File metadata and controls
57 lines (47 loc) · 1.03 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
#ifndef SORTALGORITHMS_ALGORITHM_INTERFACE_H
#define SORTALGORITHMS_ALGORITHM_INTERFACE_H
#include <iostream>
#include <vector>
#include <string>
#include "assert.h"
namespace algorithm_ns
{
class AlgorithmInterface
{
public:
virtual void
initialize(std::string name, std::vector<int> &nums)
{
name_ = name;
nums_ = nums;
}
virtual void
printNums()
{
for (const auto &n : nums_)
{
std::cout << n << " ";
}
std::cout << std::endl;
}
virtual std::string
getName()
{
return name_;
}
virtual void
check()
{
for (int i = 0; i < nums_.size()-1; i++)
{
assert(nums_[i] <= nums_[i + 1]);
}
}
virtual void
sort() = 0;
protected:
std::vector<int> nums_;
std::string name_;
};
}
#endif //SORTALGORITHMS_ALGORITHM_INTERFACE_H