Exemplo n.º 1
0
        public void Testing()
        {
            var trie = new PatriciaTrie <int>();

            trie.Insert("SOME", 1);
            trie.Insert("ABACUS", 2);
            trie.Insert("SOMETHING", 3);
            trie.Insert("B", 4);
            trie.Insert("ABRACADABRA", 5);
            trie.Insert("THIS", 6);
            trie.Insert("SOMERSET", 7);



            trie.Delete("ABACUS");

            var test1 = trie.Find("SOME");
            var test2 = trie.Find("ABACUS");
            var test3 = trie.Find("SOMETHING");
            var test4 = trie.Find("B");
            var test5 = trie.Find("ABRACADABRA");
            var test6 = trie.Find("THIS");
            var test7 = trie.Find("SOMERSET");
            var test8 = trie.Find("SQUIRREL");
        }
Exemplo n.º 2
0
        public void PatriciaTrie_Insert_Successful()
        {
            _patriciaTrie.Insert("aaabbb", 1);
            _patriciaTrie.Insert("aaaccd", 2);
            _patriciaTrie.Insert("aaacce", 3);
            _patriciaTrie.Insert("aaaccdaaa", 4);
            _patriciaTrie.Insert("aaaccdaaaccc", 5);

            _patriciaTrie.Delete("aaacce");

            Assert.AreEqual("['' (a)] ['aaa' (b c)] ['bbb' () 1] ['cc' (d e)] ['d' () 2] ['e' () 3] ", _patriciaTrie.ToString());
        }
Exemplo n.º 3
0
        public void TestDelete()
        {
            var memDb = new MemoryDictionarySource();
            var trie  = new PatriciaTrie(memDb);

            trie.Put(dog, cat);

            byte[] dogCatOnlyHash = trie.GetRootHash();

            trie.Put(fish, bird);
            trie.Delete(fish);

            Assert.Equal(dogCatOnlyHash, trie.GetRootHash());

            trie.Put(fish, bird);
            trie.Put(fish, empty);

            Assert.Equal(dogCatOnlyHash, trie.GetRootHash());
        }