-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrie.h
More file actions
32 lines (22 loc) · 800 Bytes
/
Copy pathtrie.h
File metadata and controls
32 lines (22 loc) · 800 Bytes
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
/* This library implements a Trie data structure for storing a dictionary
as described here: https://en.wikipedia.org/wiki/Trie
See implementation file trie.c for function documentation. */
#ifndef TRIE_H
#define TRIE_H
#include <stdbool.h>
#define INITIAL_TRIE_CHILDREN 8
typedef char TrieValue_t;
typedef struct Trie_s {
TrieValue_t value;
bool endOfString;
size_t numChildren;
size_t childrenCapacity;
struct Trie_s ** children; //these will point to Trie_t's
} Trie_t;
Trie_t * newTrie(TrieValue_t value, bool endOfString);
void destroyTrie(Trie_t * tree);
bool insertStringToTrie(Trie_t * tree, TrieValue_t * string);
bool stringExistsInTrie(Trie_t * tree, TrieValue_t * string);
Trie_t * newTrieFromDictionary(char * dictionaryFileName);
void testTrie();
#endif