-
Notifications
You must be signed in to change notification settings - Fork 1
/
Node.h
73 lines (58 loc) · 1.37 KB
/
Node.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef NODE_H
#define NODE_H
class Node {
private:
bool leafNode;
unsigned int attribute;
unsigned int count;
std::vector<unsigned int> childrenLabels;
std::vector<Node *> children;
public:
Node();
~Node();
void setAttribute(unsigned int attribute);
unsigned int getAttribute();
void insertChild(Node* node, unsigned int label);
std::vector<Node *> getChildren();
std::vector<unsigned int> getChildrenLabels();
void setCount(unsigned int count);
unsigned int getCount();
void setLeaf();
bool isLeaf();
};
Node::Node(){
this->leafNode = false;
}
Node::~Node(){
for(unsigned int i=0; i<children.size(); i++)
delete children[i];
}
void Node::setAttribute(unsigned int attribute){
this->attribute = attribute;
}
unsigned int Node::getAttribute(){
return this->attribute;
}
void Node::insertChild(Node* node, unsigned int label){
this->children.push_back(node);
this->childrenLabels.push_back(label);
}
std::vector<Node *> Node::getChildren(){
return this->children;
}
std::vector<unsigned int> Node::getChildrenLabels(){
return this->childrenLabels;
}
void Node::setCount(unsigned int count){
this->count = count;
}
unsigned int Node::getCount(){
return this->count;
}
void Node::setLeaf(){
this->leafNode = true;
}
bool Node::isLeaf(){
return this->leafNode;
}
#endif