forked from shaobohou/madios
-
Notifications
You must be signed in to change notification settings - Fork 2
/
RDSNode.cpp
63 lines (51 loc) · 1.16 KB
/
RDSNode.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
#include "RDSNode.h"
using std::vector;
RDSNode::RDSNode()
{
this->lexicon = 0;
}
RDSNode::RDSNode(LexiconUnit *lexicon, LexiconTypes::LexiconEnum type)
{
this->lexicon = lexicon;
this->type = type;
}
RDSNode::RDSNode(const RDSNode &other)
{
deepCopy(other);
}
RDSNode::~RDSNode()
{
if(lexicon) delete lexicon;
}
RDSNode& RDSNode::operator=(const RDSNode &other)
{
deepCopy(other);
return *this;
}
void RDSNode::addConnection(const Connection &con)
{
connections.push_back(con);
}
const vector<Connection>& RDSNode::getConnections() const
{
return connections;
}
void RDSNode::setConnections(const vector<Connection> &connections)
{
this->connections = connections;
}
bool RDSNode::addParent(const Connection &newParent)
{
for(unsigned int i = 0; i < parents.size(); i++)
if(parents[i] == newParent)
return false;
parents.push_back(newParent);
return true;
}
void RDSNode::deepCopy(const RDSNode &other)
{
lexicon = other.lexicon->makeCopy();
type = other.type;
connections = other.connections;
parents = other.parents;
}