41 #include "EST_String.h" 42 #include "EST_StringTrie.h" 47 static void (* trie_delete_function)(
void *n) = 0;
49 static inline int char2idx(
unsigned char k)
55 EST_TrieNode::EST_TrieNode(
const int width)
64 EST_TrieNode::~EST_TrieNode()
68 if (trie_delete_function != 0)
69 trie_delete_function(contents);
83 int idx = char2idx(*key);
87 return d[idx]->
lookup(key+1);
97 trie.
add(path,contents);
99 for (
int i=0; i < w; i++)
119 int idx = char2idx(*key);
122 d[idx]->
add(key+1,value);
126 EST_StringTrie::EST_StringTrie()
139 EST_StringTrie::~EST_StringTrie()
146 const unsigned char *ckey = (
const unsigned char *)(
void *)(
const char *)key;
147 return tree->lookup(ckey);
152 const unsigned char *ckey = (
const unsigned char *)(
void *)(
const char *)key;
153 tree->add(ckey,item);
166 trie_delete_function = deletenode;
168 trie_delete_function = 0;
void * lookup(const unsigned char *key) const
Find the contents for given string, 0 if no current contents.
void add(const EST_String &key, void *item)
Add { item} indexed by { key}, overwriting previous contents.
void clear(void)
Delete the tree.
void add(const unsigned char *key, void *item)
add { item} for { key} overwriting previous contents
void copy_into(EST_StringTrie &trie, const EST_String &path) const
copy all entries in trie node into trie
void * lookup(const EST_String &key) const
Find contents index by { key}, 0 if there is not contents.