aboutsummaryrefslogtreecommitdiff
path: root/trie.h
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@hornquist.se>2019-02-19 10:05:45 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2019-02-19 10:18:33 +0100
commitecd15e3f6731a8298e9cd3ebc45e1875e8c19063 (patch)
treed976a5fd710cc39350a37a2aa2f37fd08d0926f5 /trie.h
parentNo idea, to tired. (diff)
downloadcalp-ecd15e3f6731a8298e9cd3ebc45e1875e8c19063.tar.gz
calp-ecd15e3f6731a8298e9cd3ebc45e1875e8c19063.tar.xz
Now it links, but segfaults.
Diffstat (limited to 'trie.h')
-rw-r--r--trie.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/trie.h b/trie.h
index 07c1bce3..4613694e 100644
--- a/trie.h
+++ b/trie.h
@@ -3,25 +3,25 @@
#include <iostream>
-template <typename T>
+template <class T>
struct trie_node {
char c;
T* value = NULL;
trie_node<T>* next = nullptr;
trie_node<T>* child = nullptr;
- trie_node (char c);
+ trie_node (char c) : c(c) { };
trie_node (char c, trie_node<T>* next, trie_node<T>* child);
};
template <class T>
std::ostream& operator<<(std::ostream&, trie_node<T>* node);
-template <typename T>
+template <class T>
struct trie {
trie_node<T>* root;
- trie ();
+ trie () : root (new trie_node<T> ('\0')) { }
int push_back (const char* key, const T&);