public void TestMultiTrie() { Trie t = new MultiTrie(true); string[] keys = { "a", "ba", "bb", "c" }; string[] vals = { "1", "2", "2", "4" }; for (int i = 0; i < keys.Length; i++) { t.Add(keys[i], vals[i]); } AssertTrieContents(t, keys, vals); }
/// <summary> /// Remove empty rows from the given <see cref="Trie"/> and return the newly reduced <see cref="Trie"/>. /// </summary> /// <param name="by">the <see cref="Trie"/> to reduce</param> /// <returns>the newly reduced Trie</returns> public override Trie Reduce(Reduce by) { List<Trie> h = new List<Trie>(); foreach (Trie trie in tries) h.Add(trie.Reduce(by)); MultiTrie m = new MultiTrie(forward); m.tries = h; return m; }
internal static Trie LoadTrie(string path) { Trie trie; using (DataInputStream @is = new DataInputStream( new FileStream(path, FileMode.Open, FileAccess.Read))) { string method = @is.ReadUTF().ToUpperInvariant(); if (method.IndexOf('M') < 0) { trie = new Trie(@is); } else { trie = new MultiTrie(@is); } } return trie; }