コード例 #1
0
        public void BurstTrie_ContainsTwo()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("con");
            trie.Add("zip");
            Assert.IsTrue(trie.Contains("con"));
            Assert.IsTrue(trie.Contains("zip"));
        }
コード例 #2
0
        public void BurstTrie_Blank()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("");
            Assert.IsTrue(trie.Contains(""));
        }
コード例 #3
0
        public void BurstTrie_NotContainsUnrelated()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("a");
            Assert.IsFalse(trie.Contains("b"));
        }
コード例 #4
0
        public void BurstTrie_SuperstringNotContained()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("a");
            Assert.IsFalse(trie.Contains("aa"));
        }
コード例 #5
0
        public void BurstTrie_BurstBucket()
        {
            // 32 is current limit; revisit?
            string    s    = "test";
            BurstTrie trie = new BurstTrie();

            for (int i = 0; i < 33; i++)
            {
                trie.Add(s);
                s += i.ToString();
            }
            Assert.IsTrue(trie.Contains("test"));
            Assert.IsTrue(trie.Contains("test0"));
            Assert.IsTrue(trie.Contains("test01"));
            Assert.IsFalse(trie.Contains("est"));
            Assert.IsFalse(trie.Contains("est0"));
        }
コード例 #6
0
        public void BurstTrie_FailedString()
        {
            string    s    = @"  You may copy it, give it away or\r\nre-use it under the terms of the Project Gutenberg License included\r\nwith this eBook or online at www";
            BurstTrie trie = new BurstTrie();

            trie.Add(s);
            Assert.IsTrue(trie.Contains(s));
        }
コード例 #7
0
        public void BurstTrie_NotContained()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("con");
            Assert.IsFalse(trie.Contains("coo"));
            Assert.IsFalse(trie.Contains("cona"));
            Assert.IsFalse(trie.Contains("ocon"));
            Assert.IsFalse(trie.Contains("noc"));
            Assert.IsFalse(trie.Contains("cno"));
            Assert.IsFalse(trie.Contains("ocn"));
            Assert.IsFalse(trie.Contains("ccc"));
            Assert.IsFalse(trie.Contains("nnn"));
            Assert.IsFalse(trie.Contains("ooo"));
        }
コード例 #8
0
        public void BurstTrie_EnglishWordsPerf()
        {
            string[]  strings = _englishWords;
            BurstTrie trie    = new BurstTrie();

            foreach (string s in strings)
            {
                trie.Add(s);
            }
            foreach (string s in strings)
            {
                Assert.IsTrue(trie.Contains(s));
            }
        }
コード例 #9
0
        public void BurstTrie_MultiNotContained()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("con");
            trie.Add("cono");
            trie.Add("foo");
            trie.Add("fon");
            trie.Add("fondue");

            Assert.IsTrue(trie.Contains("con"));
            Assert.IsTrue(trie.Contains("fon"));
            Assert.IsTrue(trie.Contains("fondue"));
            Assert.IsFalse(trie.Contains("fo"));
            Assert.IsFalse(trie.Contains("cor"));
            Assert.IsFalse(trie.Contains("corse"));
            Assert.IsFalse(trie.Contains("fondu"));
            Assert.IsFalse(trie.Contains("f"));
            Assert.IsFalse(trie.Contains("x"));
        }
コード例 #10
0
        public void BurstTrie_BurstBucketSimple()
        {
            BurstTrie trie = new BurstTrie();

            BurstTrie.BurstThreshold = 5;

            string s = "TE";

            for (int i = 0; i < 7; i++)
            {
                trie.Add(s + (char)(65 + i));
            }
            Assert.IsTrue(trie.Contains("TEA"));
            Assert.IsTrue(trie.Contains("TEB"));
            Assert.IsTrue(trie.Contains("TEC"));
            Assert.IsTrue(trie.Contains("TED"));
            Assert.IsTrue(trie.Contains("TEE"));
            Assert.IsTrue(trie.Contains("TEF"));
            Assert.IsFalse(trie.Contains("TE"));
            Assert.IsFalse(trie.Contains("EA"));
            Assert.IsFalse(trie.Contains("A"));
        }
コード例 #11
0
        public void BurstTrie_NonBurstBucketSimple()
        {
            // 32 is current limit; revisit?
            BurstTrie trie = new BurstTrie();

            BurstTrie.BurstThreshold = 10;

            string s = "TE";

            for (int i = 0; i < 7; i++)
            {
                trie.Add(s + (char)(65 + i));
            }
            Assert.IsTrue(trie.Contains("TEA"));
            Assert.IsTrue(trie.Contains("TEB"));
            Assert.IsTrue(trie.Contains("TEC"));
            Assert.IsTrue(trie.Contains("TED"));
            Assert.IsTrue(trie.Contains("TEE"));
            Assert.IsTrue(trie.Contains("TEF"));
            Assert.IsFalse(trie.Contains("TE"));
            Assert.IsFalse(trie.Contains("EA"));
            Assert.IsFalse(trie.Contains("A"));
        }
コード例 #12
0
        public void BurstTrie_Empty()
        {
            BurstTrie trie = new BurstTrie();

            Assert.IsFalse(trie.Contains(""));
        }
コード例 #13
0
        public void BurstTrie_SubstringNotContained()
        {
            BurstTrie trie = new BurstTrie();

            trie.Add("abcde");
            Assert.IsFalse(trie.Contains("a"));
            Assert.IsFalse(trie.Contains("ab"));
            Assert.IsFalse(trie.Contains("abc"));
            Assert.IsFalse(trie.Contains("abcd"));
            Assert.IsFalse(trie.Contains("bcde"));
            Assert.IsFalse(trie.Contains("cde"));
            Assert.IsFalse(trie.Contains("de"));
            Assert.IsFalse(trie.Contains("e"));
            Assert.IsFalse(trie.Contains("b"));
            Assert.IsFalse(trie.Contains("c"));
            Assert.IsFalse(trie.Contains("d"));
        }