-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridRoot.h
59 lines (55 loc) · 1.22 KB
/
GridRoot.h
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
#pragma once
#include <vector>
class GridRoot {
protected:
size_t root_length;
std::vector<size_t> root_members;
public:
GridRoot() {
this->root_length = 0;
this->root_members.clear();
}
GridRoot(std::vector<size_t> members) {
this->root_length = members.size();
this->root_members.clear();
for (unsigned int i = 0; i < members.size(); i++) {
this->root_members.push_back(members[i]);
}
}
void clear() {
root_length = 0;
root_members.clear();
}
int size() {
return root_length;
}
size_t member(unsigned int n) {
return root_members[n % root_members.size()];
}
void set(std::vector<size_t> members) {
this->root_length = members.size();
}
void push(size_t member) {
this->root_length += 1;
this->root_members.push_back(member);
}
bool includes(size_t member) {
for (unsigned int i = 0; i < root_members.size(); i++) {
if (root_members[i] == member) {
return true;
}
}
return false;
}
bool isMatching(GridRoot &g) {
if (g.root_length != this->root_length) {
return false;
}
for (unsigned int i = 0; i < g.root_members.size(); i++) {
if (!this->includes(g.root_members[i])) {
return false;
}
}
return true;
}
};