-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlist.cpp
214 lines (178 loc) · 3.96 KB
/
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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#include "list.h"
#include <math.h>
#include <iostream>
list::list(){
toP = 0;
boT = 0;
acT = 0;
Id = 0;
stepHST = 1.0 / (double)HIST_VO_;
}
list::~list(){
;
}
void list::push(unsigned int blX, unsigned int blY, unsigned int trX, unsigned int trY, unsigned int inCard){
// push - inserts a new element (bottomleft, topright and inCard)
card* Card = new card();
if(toP == 0)toP = karta;
Id++;
Card->blX = blX;
Card->blY = blY;
Card->trX = trX;
Card->trY = trY;
Card->next = boT;
Card->Id = Id;
Card->idCard = idCard;
if(Card->next != 0)Card->next->prev = Card;
Card->prev = 0;
Card->Card = 0;
boT = Card;
acT = Card;
for(unsigned int i = 0; i < HIST_VO_; i++){
Card->ffT[i] = 0.0; // reset this matrix to add items to the histogram
}
}
bool list::top(){
bool re = true;;
if(boT != 0){
acT = toP;
} else {
re = false;
}
return re;
}
bool list::bot(){
bool re = true;
if(boT != 0){
acT = boT;
} else {
re = false;
}
return re;
}
bool list::prev(){
bool re = true;;
if(acT != 0){
acT = acT->prev;
} else {
re = false;
}
return re;
}
bool list::next(){
bool re = true;
if(acT != 0){
acT = acT->next; // if this current element exists then set pointer to whichever is next
re = acT != 0; // if not zero then there is a successor, and if not it was the last card
} else {
re = false; // false is when act is zero
}
return re;
}
bool list::empty(){
return (toP == 0); // top is zero when the list is empty
}
void list::get(unsigned int &blX, unsigned int &blY, unsigned int &trX, unsigned int &trY, unsigned int &Id){
blX = acT->blX;
blY = acT->blY;
trX = acT->trX;
trY = acT->trY;
Id = acT->Id;
}
/*
this function set the value to 2, 7, 8, 9
*/
void list::setCard(int cardValue){
acT->cardValue = card;
}
void list::setCardColor(int cardValue){ // set card color to 0, 1, 2, 3
acT->cardValue = card;
}
void listA::setColor(int color){ // set card color to 0, 1 [black, red]
acT->Color = card;
}
int list::getCard(){ // get the value from the current card
return acT->cardValue;
}
int list::getColor(){ // get the suit of the current card
return acT->color;
}
int list::getColor(){
return acT->cardValue;
}
bool list::next(unsigned int inCard){
bool re = false;
if(acT != 0){
while(acT->next != 0){
acT = acT->next;
if(acT->idCard == inCard){
re = true;
break;
}
}
}
return re;
}
bool list::bot(unsigned int inCard){
bool re = false;
if(boT != 0){
acT = boT;
if(acT->idCard == inCard){
re = true;
} else {
re = next(inCard);
}
} else {
re = false;
}
return re;
}
unsigned int list::getId(){ // get the id from the current element
return acT->Id;
}
bool list::goId(unsigned int Id){ // go to the specified id
bool re = false;
if(boT != 0){
acT = boT;
if(acT->Id == Id){
re = true;
} else {
while(acT->next != 0){
acT = acT->next;
if(acT->Id == Id){
re = true;
break;
}
}
}
} else {
re = false;
}
return re;
}
void list::getC(double &xC, double &yC) {
xC = acT->xC;
yC = acT->yC;
}
bool list::findCard(int card, int color) {
bool re = false, go = true;
if (bot(0)) {
while (go) {
if (acT->card == card && acT->color == color) {
re = true;
break;
}
go = next(0);
}
}
return re;
}
bool list::top(){
bool re = true;;
if(boT != 0){
acT = toP;
} else {
re = false;
}
return re;
}