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
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
#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;
            }
        }
    }
}