#include "trie.hpp"
#include <iostream> 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'; } }; int main() { Trie<double, Key> trie; trie.insert("Lehn", 42); trie.insert("lehn", 123); trie.insert("le", 666); trie.insert("leH", 4242); std::string key = "lehn"; Trie<double, Key>::Pointer ptr = trie.descend(); if (ptr.defined()) { for (char ch: key) { if (!ptr.descend(ch)) break; if (ptr.exists()) { std::cout << *ptr << std::endl; } } } } |