#ifndef TRIE_H #define TRIE_H #include template struct trie_node { char c; T* value = NULL; trie_node* next = nullptr; trie_node* child = nullptr; trie_node (char c) : c(c) { }; trie_node (char c, trie_node* next, trie_node* child); }; template std::ostream& operator<<(std::ostream&, trie_node* node); template struct trie { trie_node* root; trie () : root (new trie_node ('\0')) { } int push_back (const char* key, const T&); T& operator[] ( const char* key ); bool empty () { return this->root->child == NULL; } }; template std::ostream& operator<<(std::ostream&, trie* trie); #endif /* TRIE_H */