diff options
Diffstat (limited to 'extractor/matchings_trie.cc')
-rw-r--r-- | extractor/matchings_trie.cc | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/extractor/matchings_trie.cc b/extractor/matchings_trie.cc index c7b98765..7fb7a529 100644 --- a/extractor/matchings_trie.cc +++ b/extractor/matchings_trie.cc @@ -2,19 +2,22 @@ namespace extractor { -void MatchingsTrie::Reset() { - ResetTree(root); +MatchingsTrie::MatchingsTrie() { root = make_shared<TrieNode>(); } +MatchingsTrie::~MatchingsTrie() { + DeleteTree(root); +} + shared_ptr<TrieNode> MatchingsTrie::GetRoot() const { return root; } -void MatchingsTrie::ResetTree(shared_ptr<TrieNode> root) { +void MatchingsTrie::DeleteTree(shared_ptr<TrieNode> root) { if (root != NULL) { for (auto child: root->children) { - ResetTree(child.second); + DeleteTree(child.second); } if (root->suffix_link != NULL) { root->suffix_link.reset(); |