summaryrefslogtreecommitdiff
path: root/extractor/matchings_trie.cc
blob: c7b98765fec556fad844ac50b0eba9c28b4bd909 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "matchings_trie.h"

namespace extractor {

void MatchingsTrie::Reset() {
  ResetTree(root);
  root = make_shared<TrieNode>();
}

shared_ptr<TrieNode> MatchingsTrie::GetRoot() const {
  return root;
}

void MatchingsTrie::ResetTree(shared_ptr<TrieNode> root) {
  if (root != NULL) {
    for (auto child: root->children) {
      ResetTree(child.second);
    }
    if (root->suffix_link != NULL) {
      root->suffix_link.reset();
    }
    root.reset();
  }
}

} // namespace extractor