-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepresentations.cpp
95 lines (80 loc) · 1.56 KB
/
representations.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
#include "representations.hpp"
#include <algorithm>
using namespace on_sets;
#define args begin(), end(), other.begin(), other.end(), std::inserter(s, s.begin())
card_set card_set::operator|(const card_set &other) const {
card_set s;
std::set_union(args);
return s;
}
card_set card_set::operator&(const card_set &other) const {
card_set s;
std::set_intersection(args);
return s;
}
card_set card_set::operator-(const card_set &other) const {
card_set s;
std::set_difference(args);
return s;
}
card_set card_set::operator^(const card_set &other) const {
card_set s;
std::set_symmetric_difference(args);
return s;
}
card_set card_set::operator~() const {
return ALL_CARDS - *this;
}
#undef args
symbol_list symbol_list::concat(const symbol_list &other) const {
symbol_list combined = *this;
combined.insert(this->end(), other.begin(), other.end());
return combined;
}
template<typename Func> symbol_list symbol_list::where(Func f) const {
symbol_list g;
for (auto ss : *this) {
if (f(ss)) g.push_back(ss);
}
return g;
}
bool is_color(symbol ss) {
switch (ss) {
case BLUE:
case RED:
case GREEN:
case YELLOW:
return true;
default:
return false;
}
}
bool is_universal(symbol ss) {
switch (ss) {
case UNIVERSE:
case EMPTYSET:
return true;
default:
return false;
}
}
bool is_operator(symbol ss) {
switch (ss) {
case AND:
case OR:
case MINUS:
case NOT:
return true;
default:
return false;
}
}
bool is_restriction(symbol ss) {
switch (ss) {
case EQUALS:
case SUBSET:
return true;
default:
return false;
}
}