Ejemplo n.º 1
0
        public void TestAllKeys()
        {
            var words = new[] { "one", "two", "three", "threshing" };

            var trie = new PrefixTrie(words);

            var withPrefixO = trie.AllKeys("o").ToList();

            withPrefixO.Should().BeEquivalentTo(new[] { "one" });

            var withPrefixTh = trie.AllKeys("th").ToList();

            withPrefixTh.Should().BeEquivalentTo(words.Where(w => w.StartsWith("th")));
        }
Ejemplo n.º 2
0
        public void TestAllKeys_InvalidPrefix()
        {
            var words = new[] { "one", "two", "three", "threshing" };

            var trie = new PrefixTrie(words);

            var withPrefixEmptyString = trie.AllKeys("twofold").ToList();

            withPrefixEmptyString.Should().BeEmpty();
        }
Ejemplo n.º 3
0
        public void TestAllKeys_EmptyPrefix()
        {
            var words = new[] { "one", "two", "three", "threshing" };

            var trie = new PrefixTrie(words);

            var withPrefixEmptyString = trie.AllKeys("").ToList();

            withPrefixEmptyString.Should().BeEquivalentTo(words);
        }