#ifndef _MATCHINGS_TRIE_ #define _MATCHINGS_TRIE_ #include #include #include "phrase.h" #include "phrase_location.h" using namespace std; struct TrieNode { TrieNode(shared_ptr suffix_link = shared_ptr(), Phrase phrase = Phrase(), PhraseLocation matchings = PhraseLocation()) : suffix_link(suffix_link), phrase(phrase), matchings(matchings) {} void AddChild(int key, shared_ptr child_node) { children[key] = child_node; } bool HasChild(int key) { return children.count(key); } shared_ptr GetChild(int key) { return children[key]; } shared_ptr suffix_link; Phrase phrase; PhraseLocation matchings; unordered_map > children; }; class MatchingsTrie { public: void Reset(); shared_ptr GetRoot() const; private: void ResetTree(shared_ptr root); shared_ptr root; }; #endif