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

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();
  }
}