xtralib  0.1.0
A simple header-based drop-in library
trie.h
Go to the documentation of this file.
1 
10 #ifndef __XTRA_TRIE_H__
11 #define __XTRA_TRIE_H__
12 
13 // Default to English
14 static int xtTrieNumOfLetters = 26;
15 
16 #include <xtra/common.h>
17 
18 #include <string.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <wchar.h>
22 
23 typedef struct TrieNode TrieNode;
24 struct TrieNode {
25  wchar_t data;
26  bool is_leaf;
27  TrieNode* children[];
28 };
29 
30 TrieNode * TrieNodeInit(wchar_t data, int numOfLetters);
31 void TrieNodeFree(TrieNode *node);
32 
33 TrieNode * TrieInsert(TrieNode *root, wchar_t *word);
34 TrieNode * TrieDelete(TrieNode *root, wchar_t *word);
35 
36 bool TrieSearch(TrieNode *root, wchar_t *word);
37 
38 void TriePrint(TrieNode *root);
39 bool TriePrintSearch(TrieNode *root, wchar_t *word);
40 
41 #endif
New functions and types related to string and string manipulation.
Definition: trie.h:24
TrieNode * TrieInsert(TrieNode *root, wchar_t *word)
Inserts word onto the trie.
Definition: trie.c:43
bool TrieSearch(TrieNode *root, wchar_t *word)
Searches for a given word.
Definition: trie.c:91
TrieNode * TrieDelete(TrieNode *root, wchar_t *word)
Deletes words from trie. Will try to delete the word sequence from trie only if it ends up in a leaf ...
Definition: trie.c:72