Usage
Include the header file to use the trie library.
#include "trie.tcc"
The library provides the Trie
class, which takes two template arguments,
the first of which determines the alphabet size, the second determines the
type of the leaf.
Trie<4, Leaf> trie;
vector<uint8_t> word = {0, 1, 2, 3};
trie.add(word);
Node<4, Leaf>* node = trie.find(word);
trie.remove(word);
for (Result<Leaf> result: trie.walk()) {
// result.leaf : Leaf node.
// result.path : Word leading up to the leaf.
}
for (Result<Leaf> result: trie.hamming(word, 1)) {
// result.leaf : Leaf node.
// result.path : Word leading up to the leaf.
}
struct MyLeaf : Leaf {
vector<size_t> lines;
}
size_t line = 0;
for (vector<uint8_t> word: words) {
MyLeaf* leaf = trie.add(word);
leaf->lines.push_back(line++);
}