#include <iostream>
#include "trie.hpp" struct Key { static constexpr size_t size() { return ('Z' - 'A' + 1); } static constexpr size_t map(char c) { assert(c>='a' && c<='z' || c>='A' && c<='Z'); if (c>='a' && c<='z') { c = c - 'a' + 'A'; } return c - 'A'; } static constexpr char unmap(size_t key) { assert(key<size()); return 'a' + key; } }; int main() { Trie<double, Key>::Pointer ptr; { Trie<double, Key> trie; trie.insert("lbur", 42); trie.insert("lbru", 42); trie.insert("lxvz", 123); trie.insert("foo", 111); trie.insert("le", 666); ptr = trie.descend(); } std::cout << "Here" << std::endl; std::string key = ""; do { if (ptr.defined()) { for (char ch: key) { std::cout << ch << ":" << std::endl; if (!ptr.descend(ch)) break; if (ptr.exists()) { std::cout << "FOUND: " << *ptr << std::endl; } } std::cout << "continuation possible with: "; for (char ch: ptr) { std::cout << ch << ", "; } std::cout << std::endl; } } while (std::cin >> key); } |