Example #1
0
        public virtual void TestDelete2()
        {
            NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(3);
            btree.Insert(1, "key 1");
            btree.Insert(2, "key 2");
            btree.Insert(3, "key 3");
            btree.Insert(4, "key 4");
            btree.Insert(5, "key 5");
            AssertEquals(5, btree.GetSize());
            AssertEquals("key 1", btree.Search(1));
            AssertEquals("key 2", btree.Search(2));
            AssertEquals("key 3", btree.Search(3));
            AssertEquals("key 4", btree.Search(4));
            AssertEquals("key 5", btree.Search(5));
            object o = btree.Delete(1, "key 1");

            AssertEquals("key 1", o);
            o = btree.Delete(2, "key 2");
            AssertEquals("key 2", o);
            o = btree.Delete(3, "key 3");
            AssertEquals("key 3", o);
            o = btree.Delete(4, "key 4");
            AssertEquals("key 4", o);
            o = btree.Delete(5, "key 5");
            AssertEquals("key 5", o);
            AssertEquals(0, btree.GetSize());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
        }
Example #2
0
        public virtual void TestDelete()
        {
            NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(3);
            btree.Insert(1, "key 1");
            AssertEquals(1, btree.GetSize());
            AssertEquals("key 1", btree.Search(1));
            object o = btree.Delete(1, "key 1");

            AssertEquals("key 1", o);
            AssertEquals(0, btree.GetSize());
            AssertEquals(1, btree.GetHeight());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
        }
Example #3
0
        public virtual void TestDelete100000Alpha_2()
        {
            NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(2);
            int size = 100000;

            for (int i = 0; i < size; i++)
            {
                btree.Insert("key" + i, "value " + i);
            }
            object o = btree.Search("key71");

            AssertEquals(size, btree.GetSize());
            for (int i = size - 1; i >= 0; i--)
            {
                // println(new BTreeDisplay().build(btree));
                AssertEquals("value " + i, btree.Delete("key" + i, "value " + i));
            }
            AssertEquals(0, btree.GetSize());
            AssertEquals(1, btree.GetHeight());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
            AssertEquals(0, btree.GetRoot().GetNbChildren());
        }