test
[ws10smt.git] / extools / suffix_tree.h
blobd3a9c08e5f37b82d57bf35551e27e9ae5b804401
1 /*
2 * suffix_tree.h
4 * Created on: May 17, 2010
5 * Author: Vlad
6 */
8 #ifndef SUFFIX_TREE_H_
9 #define SUFFIX_TREE_H_
11 #include <string>
12 #include <map>
13 #include <vector>
15 template <class T>
16 class Node {
17 public:
18 std::map<T, Node> edge_list_;
19 int InsertPath(const std::vector<T>& p, int start, int end);
20 const Node* Extend(const T& e) const {
21 typename std::map<T, Node>::const_iterator it = edge_list_.find(e);
22 if (it == edge_list_.end()) return NULL;
23 return &it->second;
27 bool DEBUG = false;
29 template <class T>
30 int Node<T>::InsertPath(const std::vector<T>& p, int start, int end){
31 Node* currNode = this;
32 for(int i=start;i<= end; i++ ) {
33 currNode = &(currNode->edge_list_)[p[i]];
35 return 1;
38 #endif /* SUFFIX_TRIE_H_ */