Example #1
0
		SuffixTree(string s)
		{
			for (int i = 0; i < s.length(); ++i)
			{
				string suffix = s.substr (i);
				root.insertString (suffix, i);
			}
		}
 void insertString(const string &s, int index) {
     indexes.push_back(index);
     if (s.length() > 0) {
         value = s[0];
         SuffixTreeNode child;
         if (children.find(value) != children.end()) {
             child = children[value];
         } else {
             children.insert(make_pair(value, child));
         }
         string remainder = s.substr(1);
         child.insertString(remainder, index);
     }
 }
 SuffixTree(const string &s) {
     for (int i = 0; i < s.length(); i++) {
         string suffix = s.substr(i);
         root.insertString(suffix, i);
     }
 }