aboutsummaryrefslogtreecommitdiff
path: root/trie.h
blob: 5145957eae1591276ca62a90432275c31e784d7e (plain)
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
45
46
#ifndef TRIE_H
#define TRIE_H

#include <stdio.h>

#include "macro.h"

// #define TRIE(T)      TEMPL(trie, T)
// #define TRIE_NODE(T) TEMPL(trie_node, T)

// #endif /* TRIE_H */
// #ifdef TYPE

template<class T> struct trie_node {
	char c;
	T* value;
	trie_node* next;
	trie_node* child;

	trie_node (char c);
	trie_node (char c, trie_node* next, trie_node* child);

	~trie_node ();
};

template<class T> struct trie {
	trie_node<T>* root;

	trie ();
	~trie();

	int push (char* key, T* val);
	T* get (char* key);

	int empty ();
};

// FMT_F(TRIE_NODE(TYPE));
// FMT_F(TRIE(TYPE));

// extern template struct trie<content_line>;
// extern template struct trie_node<content_line>;

#include "trie.c.inc"

#endif /* TYPE */