-
Notifications
You must be signed in to change notification settings - Fork 0
/
target.cpp
54 lines (47 loc) · 1.01 KB
/
target.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
#include "target.h"
Target::Target() {
spot = Spot();
to_value = 0;
}
Target::Target(Spot p, int toval) {
spot = p;
to_value = toval;
}
Target::Target(Spot p, std::vector<int> cands, int toval) {
spot = p;
candidates = cands;
to_value = toval;
}
void Target::apply(BitMatrix* bits) {
if(to_value != 0) {
bits->set_value(spot, to_value);
} else {
for(int i=0; i < candidates.size(); i++) {
bits->remove_candidate(spot, candidates[i]);
}
}
}
std::ostream& operator<<(std::ostream& out, Target& target) {
/*
out << "[" << target.spot << " [";
if(target.candidates.size() != 0) {
out << target.candidates[0];
}
for(int i=1; i < target.candidates.size(); i++) {
out << " " << target.candidates[i];
}
out << "] -> " << target.to_value << "]";
return out;
*/
out << target.spot;
if(target.candidates.size() != 0) {
out << " !=";
for(int i=0; i < target.candidates.size(); i++) {
out << target.candidates[i];
}
}
if(target.to_value != 0) {
out << " -> " << target.to_value;
}
return out;
}