-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_deque_list.cpp
47 lines (43 loc) · 1.25 KB
/
test_deque_list.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
#include <iostream>
#include <deque>
#include <list>
#include "edit_distance.h"
template <typename T>
struct modulo_equal
{
int val;
modulo_equal(int v): val(v) {}
bool operator() (T a, T b) const { return a % val == b % val; }
};
template <typename T>
void print_seq(T v)
{
std::cout << "[";
for (auto item: v) {
std::cout << item << " ";
}
std::cout << "\b]";
std::cout << "\n";
}
int main()
{
int ham, lev, osa;
std::deque a1 {10, 11, 12, 13, 14, 15};
std::list b1 {10, 12, 22, 14, 13, 15};
EditDistance d1(begin(a1), end(a1), begin(b1), end(b1),
Cost{}, modulo_equal<int>(10));
ham = d1.hamming();
lev = d1.lev();
osa = d1.osa();
std::cout << "Test Case 1\n";
std::cout << "deque and list:\n";
print_seq(a1);
print_seq(b1);
std::cout << "Deque and list with modulo 10 equality\n";
std::cout << "------------------------------------------------------\n";
std::cout << "hamming distance : " << ham << "\n";
std::cout << "levenshtein distance : " << lev << "\n";
std::cout << "optimal string alignment distance : " << osa << "\n";
std::cout << "------------------------------------------------------\n\n";
return 0;
}