@@ -21,7 +21,7 @@ class SuffixTree
2121{
2222public:
2323// 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() {}
2525int construct (void );
2626
2727// 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
8282
8383struct Edge {
8484// 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;
8686// Is there a better way to find test_str?
8787string& test_node_str;
8888
8989Node * endpoint;
9090
91- Edge (int b, int e, string& str):
91+ Edge (unsigned int b, unsigned int e, string& str):
9292test_node_str (str)
9393{
9494begin = b;
@@ -97,7 +97,7 @@ class SuffixTree
9797// std::cout << "Edge initialized" << std::endl;
9898}
9999
100- void change_edge (int b, int e)
100+ void change_edge (unsigned int b, unsigned int e)
101101{
102102begin = b;
103103end = e;
@@ -118,7 +118,7 @@ class SuffixTree
118118return me.begin < other.begin ;
119119}
120120
121- char operator [](int i)
121+ char operator [](unsigned int i)
122122{
123123i += begin;
124124if (i > end)
@@ -129,12 +129,12 @@ class SuffixTree
129129
130130friend ostream& operator <<(ostream& os, Edge& edge)
131131{
132- int end = edge.test_node_str .size ()-1 ;
132+ unsigned int end = edge.test_node_str .size ()-1 ;
133133if (end >= edge.end )
134134end = edge.end ;
135135
136136char c;
137- for (int i=edge.begin ; i<=end; i++) {
137+ for (unsigned int i=edge.begin ; i<=end; i++) {
138138c = edge.test_node_str [i];
139139os << c;
140140}
@@ -246,7 +246,7 @@ class SuffixTree
246246// how many suffixes is to be inserted?
247247int remainder;
248248// how many characters inserted?
249- int pos;
249+ unsigned int pos;
250250char get_ele (int i) { return test_str[i]; }
251251// insert a char from pos to suffix tree
252252int insert ();
0 commit comments