-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAbstractMethodSearching.cpp
More file actions
84 lines (69 loc) · 2.33 KB
/
AbstractMethodSearching.cpp
File metadata and controls
84 lines (69 loc) · 2.33 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "stdafx.h"
#include "AbstractMethodSearching.h"
vector<ByteVector>* MethodSearching::AbstractMethodSearching::getReorderedNums() {
if (reorderednums == nullptr)addReorderedNums();
if (reorderednums == nullptr)throw 1;
return reorderednums;
}
void MethodSearching::AbstractMethodSearching::printReorderedNums() {
clog << endl;
clog << "Input Data" << endl;
for (auto it = reorderednums->begin(); it != reorderednums->end(); it++)
{
clog << *it << " " << elements->at(*it) << endl;
}
clog << endl;
}
void MethodSearching::AbstractMethodSearching::printSet(set * const printedset) {
clog << "{ ";
for (auto i = printedset->begin(); i != printedset->end(); i++)
{
clog << *i << ", ";
}
clog << "}";
}
void MethodSearching::AbstractMethodSearching::printSet(set * const printedset, func * const function) {
clog << "{ ";
for (auto i = printedset->begin(); i != printedset->end(); i++)
{
clog << *i << ":" << function->at(*i) << ", ";
}
clog << "}" << endl;
}
void MethodSearching::AbstractMethodSearching::addReorderedNums() {
if (reorderednums == nullptr) {
reorderednums = new vector<ByteVector>();
for (func::iterator it = elements->begin(); it != elements->end(); ++it) {
reorderednums->push_back(it->first);
}
}
random_shuffle(reorderednums->begin(), reorderednums->end());
}
MethodSearching::AbstractMethodSearching::AbstractMethodSearching(ByteVector vectors[], funcvalue values[], int size) {
elements = new func();
reorderednums = nullptr;
for (size_t i = 0; i <size; i++)
{
ByteVector n_vector = ByteVector(vectors[i]);
elements->insert(pair<ByteVector, funcvalue>(n_vector, values[i]));
//reorderednums->push_back(n_vector);
}
}
MethodSearching::AbstractMethodSearching::AbstractMethodSearching(const vector<ByteVector>& vectors, const vector<funcvalue>& values) {
int size = vectors.size() > values.size() ? values.size() : vectors.size();
elements = new func();
reorderednums = nullptr;
for (size_t i = 0; i <size; i++)
{
ByteVector n_vector = ByteVector(vectors[i]);
elements->insert(pair<ByteVector, funcvalue>(n_vector, values[i]));
//reorderednums->push_back(n_vector);
}
}
MethodSearching::AbstractMethodSearching::~AbstractMethodSearching() {
delete reorderednums;
/* for (func::iterator it = elements->begin(); it != elements->end(); ++it) {
delete it->first;
}*/
delete elements;
}