Trie Class Library for C#. Support for word insertion and membership checking
Get an instance of Trie using either of the following constructors
Trie trie = new Trie();
string[] words = new string[] { "SOME", "WORDS", "HERE" };
Trie trie = new Trie(words);
string filepath = @"path/to/dictionary/file"
Trie trie = new Trie(filepath);
You can add new words to the trie using the public Insert method.
Trie trie = new Trie();
trie.Insert("HELLO");
trie.Insert("WORLD");
You can use the public Contains method to check for membership (case-sensitive).
Trie trie = new Trie();
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("HELLO")); // False
Console.Insert("HELLO");
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("HELLO")); // True
Console.WriteLine("HELLO in Trie? {0}", trie.Contains("hello")); // False because it is case-sensitive
More info on tries on Wikipedia.