-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodedfa.cpp
More file actions
66 lines (53 loc) · 1.05 KB
/
nodedfa.cpp
File metadata and controls
66 lines (53 loc) · 1.05 KB
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
#include "nodedfa.h"
#include <QString>
NodeDFA::NodeDFA(QString name)
{
nextNodes = new QMap<char, NodeDFA *>();
this->name = name;
setNotFinite();
}
NodeDFA::NodeDFA(int num)
{
nextNodes = new QMap<char, NodeDFA *>();
this->name = "q";
this->name.append(char('0' + num));
setNotFinite();
}
QString NodeDFA::getName()
{
return name;
}
void NodeDFA::link(char value, NodeDFA *second)
{
nextNodes->insert(value, second);
}
void NodeDFA::link(char value)
{
nextNodes->insert(value, this);
}
NodeDFA* NodeDFA::nextNode(char value)
{
if (nextNodes->contains(value))
return nextNodes->value(value);
else
return NULL;
}
void NodeDFA::setFinite()
{ finite = true; }
void NodeDFA::setNotFinite()
{ finite = false; }
bool NodeDFA::isFiniteState()
{ return finite; }
void NodeDFA::setnextNodes( QMap<char, NodeDFA*>* nextnodes)
{
this->nextNodes = nextnodes ;
}
QMap<char, NodeDFA*>* NodeDFA::getnextNodes()
{
return nextNodes;
}
NodeDFA::~NodeDFA()
{
nextNodes->clear();
delete nextNodes;
}