Exemple #1
0
        public void DeleteTest()
        {
            trie.Insert("Word3", null);
            trie.Insert("Word2", 22);
            trie.Insert("Word1", null);
            trie.Insert("OtherWord3");
            trie.Insert("OtherWord2");
            trie.Insert("OtherWord1");

            trie.Delete("Word2");
            trie.Delete("OtherWord2");

            trie.AssertNodes(
                new TrieNode("Word3", null),
                new TrieNode("Word1", null),
                new TrieNode("OtherWord3", null),
                new TrieNode("OtherWord1", null));

            trie.Delete("OtherWord1");
            trie.Delete("Word3");
            trie.AssertNodes(
                new TrieNode("Word1", null),
                new TrieNode("OtherWord3", null));

            trie.Delete("OtherWord3");
            trie.Delete("OtherWord3");
            trie.AssertNodes(new TrieNode("Word1", null));

            trie.Delete("Word1");
            CollectionAssertEx.IsEmpty(TrieTestHelper.CollectKeys(trie));
        }
Exemple #2
0
 public static void AssertNodes(this Trie <int?> @this, params TrieNode[] expected)
 {
     CollectionAssert.AreEquivalent(expected, TrieTestHelper.CollectKeys(@this));
 }