-
Notifications
You must be signed in to change notification settings - Fork 0
/
struktury.cpp
104 lines (65 loc) · 2.15 KB
/
struktury.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "struktury.h"
int Solution::tmp;
bool lessThenVectorInt(const QVector<int> &v1, const QVector<int> &v2) {
for (int i = 0; i < v1.size(); i++) {
// qDebug()<<v1[i]<<"<"<<v2[i]<<"\n";
if (v1[i] < v2[i])
{
//qDebug()<<"true\n";
return true;
}
else if((v1[i] > v2[i]))
{
return false;
}
}
// qDebug()<<"false\n";
return false;
};
bool lessThenHiperkostka(const Hiperkostka & h1, const Hiperkostka & h2) {
return lessThenVectorInt(h1.polozenie, h2.polozenie);
};
bool equalVectorInt(const QVector<int> &v1, const QVector<int> &v2) {
for (int i = 0; i < v1.size(); i++) {
// qDebug()<<v1[i]<<"<"<<v2[i]<<"\n";
if (v1[i] != v2[i])
{
//qDebug()<<"true\n";
return false;
}
}
// qDebug()<<"false\n";
return true;
};
bool equalHiperkostka(const Hiperkostka & h1, const Hiperkostka & h2) {
return equalVectorInt(h1.polozenie, h2.polozenie);
};
void joinHiperkostki(QVector<Hiperkostka> &h)
{
for (int i = 1; i < h.size(); i++) {
if(equalHiperkostka(h[i],h[i-1]))
{
h[i-1].czasteczki+=h[i].czasteczki;
h.erase(h.begin()+i);
i--;
}
}
}
bool lessThenSolution(const Solution * s1, const Solution * s2) {
if(s1->przystosowaniePrzeskalowane[Solution::tmp]>s2->przystosowaniePrzeskalowane[Solution::tmp])
{
return true;
}
else
{
return false;
}
};
bool CrowdedComparisonOperator(const Solution * s1, const Solution * s2)
{
if(s1->ranga<s2->ranga || (s1->ranga==s2->ranga && s1->zatloczenie>s2->zatloczenie))
{
return true;
}
return false;
}