@@ -21,7 +21,7 @@ class SuffixTree
21
21
{
22
22
public:
23
23
// active point is initialized as (root, None, 0), remainder initialized as 1
24
- SuffixTree (string str):test_str(str), pos( 0 ), root(test_str), active_point(&root, 0 , 0 ), remainder(0 ), ls() {}
24
+ SuffixTree (string str):test_str(str), root(test_str), active_point(&root, 0 , 0 ), remainder( 0 ), pos (0 ), ls() {}
25
25
int construct (void );
26
26
27
27
// return -1 if no such sub exist, return the beginning postion of this substring in thr original string if it exist
@@ -82,13 +82,13 @@ class SuffixTree
82
82
83
83
struct Edge {
84
84
// the begin and end pos of this edge, note that INT_MAX stands for #(the changing end pos of this entire string)
85
- int begin, end;
85
+ unsigned int begin, end;
86
86
// Is there a better way to find test_str?
87
87
string& test_node_str;
88
88
89
89
Node * endpoint;
90
90
91
- Edge (int b, int e, string& str):
91
+ Edge (unsigned int b, unsigned int e, string& str):
92
92
test_node_str (str)
93
93
{
94
94
begin = b;
@@ -97,7 +97,7 @@ class SuffixTree
97
97
// std::cout << "Edge initialized" << std::endl;
98
98
}
99
99
100
- void change_edge (int b, int e)
100
+ void change_edge (unsigned int b, unsigned int e)
101
101
{
102
102
begin = b;
103
103
end = e;
@@ -118,7 +118,7 @@ class SuffixTree
118
118
return me.begin < other.begin ;
119
119
}
120
120
121
- char operator [](int i)
121
+ char operator [](unsigned int i)
122
122
{
123
123
i += begin;
124
124
if (i > end)
@@ -129,12 +129,12 @@ class SuffixTree
129
129
130
130
friend ostream& operator <<(ostream& os, Edge& edge)
131
131
{
132
- int end = edge.test_node_str .size ()-1 ;
132
+ unsigned int end = edge.test_node_str .size ()-1 ;
133
133
if (end >= edge.end )
134
134
end = edge.end ;
135
135
136
136
char c;
137
- for (int i=edge.begin ; i<=end; i++) {
137
+ for (unsigned int i=edge.begin ; i<=end; i++) {
138
138
c = edge.test_node_str [i];
139
139
os << c;
140
140
}
@@ -246,7 +246,7 @@ class SuffixTree
246
246
// how many suffixes is to be inserted?
247
247
int remainder;
248
248
// how many characters inserted?
249
- int pos;
249
+ unsigned int pos;
250
250
char get_ele (int i) { return test_str[i]; }
251
251
// insert a char from pos to suffix tree
252
252
int insert ();
0 commit comments