-
Notifications
You must be signed in to change notification settings - Fork 1
/
Node.cpp
85 lines (68 loc) · 1.23 KB
/
Node.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include"Node.h"
#include<vector>
#include <utility>
#include<iostream>
#include <iterator>
#include <map>
using namespace std;
int Node::sum = 0;
Node::Node()
{
isTermi = false;
}
Node::Node(int num)
{
this->num = num;
isTermi = false;
}
Node::Node(int num, bool isTer)
{
this->num = num;
isTermi = isTer;
}
Node::Node(bool isTer){
isTermi = isTer;
}
void Node::setTerminal(bool isTer){
this->isTermi = isTer;
}
bool Node::isTerminal(){
return isTermi;
}
int Node::getNum(){
return num;
}
void Node::setNum(int num){
this->num = num;
}
void Node::addOut(char on, Node* end){
out.insert(edge(on, end));
// _ASSERTE(_CrtCheckIdentifierMemory);
}
multimap<char, Node*> Node::getOutAll(){
return out;
}
typedef multimap<char, Node*>::size_type sz_type;
vector<Node*> Node::findNext(char key){
vector<Node*> s;
/*
multimap<char, Node*>::iterator position,end ;
position=out.lower_bound(key);
end = out.upper_bound(key);
while (position != end)
{
s.push_back(position->second);
++position;
}*/
sz_type cnt = out.count(key);
multimap<char, Node*>::const_iterator itr;
itr = out.find(key);
for (sz_type i = 0; i != cnt; itr++, i++)
{
s.push_back(itr->second);
}
return s;
}
int Node::getNodeSum(){
return sum;
}