-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.cpp
70 lines (51 loc) · 1.2 KB
/
State.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
//
// Created by 王若璇 on 16/11/22.
//
#include "State.h"
#include "Transition.h"
State::State() {
transition.clear();
matched = false;
visited = false;
tolStateNum++;
}
State::~State() {
}
State::State(int stateID) : stateID(stateID) {
transition.clear();
tolStateNum++;
matched = false;
visited = false;
}
State::State(int stateID, State::NodeState nodeState) : stateID(stateID), nodeState(nodeState) {
matched = false;
visited = false;
tolStateNum++;
transition.clear();
}
State::State(State::NodeState node) : nodeState(node) {
tolStateNum++;
matched = false;
visited = false;
transition.clear();
}
void State::addTransition(Transition *trans) {
nextStates.push_back(trans);
}
void State::show() {
for (int i = 0; i < nextStates.size(); i++) {
Transition *it = nextStates[i];
cout << "state " << this->stateID << " => " << it->inAccept << " => " << it->nextState->stateID << endl;
}
}
void State::showDetail() {
show();
}
void State::clean() {
}
bool State::operator<(const State &lhs) const{
return stateID<lhs.stateID;
}
bool State::operator<(State *lhs) const {
return stateID<lhs->stateID;
}