-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModeMemory.hpp
76 lines (67 loc) · 1.34 KB
/
ModeMemory.hpp
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
/*Nodeの各モードを記憶するクラス*/
#ifndef MODE_MEMORY_HEAD
#define MODE_MEMORY_HEAD
class ModeMemory{
public:
list<int> Beacon_node;
list<int> Trans_node;
list<int> ACK_node;
list<int> All_trans;
ModeMemory(){}
void addTrans(int id){
Trans_node.push_back(id);
All_trans.push_back(id);
}
void addBeacon(int id){
Beacon_node.push_back(id);
All_trans.push_back(id);
}
void addAck(int id){
ACK_node.push_back(id);
All_trans.push_back(id);
}
void deleteBeacon(int id){
list<int>::iterator it = Beacon_node.begin();
while(it != Beacon_node.end()){
if(*it == id){
Beacon_node.erase(it);
break;
}
++it;
}
deleteAllTrans(id);
}
void deleteTrans(int id){
list<int>::iterator it = Trans_node.begin();
while(it != Trans_node.end()){
if(*it == id){
Trans_node.erase(it);
break;
}
++it;
}
deleteAllTrans(id);
}
void deleteACKnodes(int id){
list<int>::iterator it = ACK_node.begin();
while(it != ACK_node.end()){
if(*it == id){
ACK_node.erase(it);
break;
}
++it;
}
deleteAllTrans(id);
}
void deleteAllTrans(int id){
list<int>::iterator it = All_trans.begin();
while(it != All_trans.end()){
if(*it == id){
All_trans.erase(it);
break;
}
++it;
}
}
};
#endif