示例#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());
        }
示例#2
0
 public virtual void TestgetBiggestSmallest1WithDelete()
 {
     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 5", btree.GetBiggest(btree.GetRoot(), true).GetValue());
     AssertEquals("key 1", btree.GetSmallest(btree.GetRoot(), true).GetValue());
     AssertEquals(null, btree.Search(1));
     AssertEquals(null, btree.Search(5));
 }
示例#3
0
 public virtual void TestInsert2()
 {
     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));
 }
示例#4
0
 public virtual void TestInsert()
 {
     NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(3);
     btree.Insert(1, "key 1");
     AssertEquals(1, btree.GetSize());
     AssertEquals("key 1", btree.Search(1));
 }
示例#5
0
 public virtual void Testsearch500()
 {
     NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(3);
     for (int i = 0; i < 500; i++)
     {
         btree.Insert(i, "key " + i);
     }
     AssertEquals(500, btree.GetSize());
     AssertEquals("key 1", btree.Search(1));
     AssertEquals("key 499", btree.Search(499));
 }
示例#6
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());
        }
示例#7
0
        public virtual void TestgetBiggestSmallest1WithDelete2()
        {
            NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(10);
            int size = 500000;

            for (int i = 0; i < size; i++)
            {
                btree.Insert(i, "key " + i);
            }
            AssertEquals(size, btree.GetSize());
            AssertEquals("key 499999", btree.GetBiggest(btree.GetRoot(), true).GetValue());
            AssertEquals("key 0", btree.GetSmallest(btree.GetRoot(), true).GetValue());
            AssertEquals(null, btree.Search(0));
            AssertEquals(null, btree.Search(499999));
        }
示例#8
0
        public virtual void Testsearch500000()
        {
            NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(10);
            int size = 500000;

            for (int i = 0; i < size; i++)
            {
                btree.Insert(i, "key " + i);
            }
            AssertEquals(size, btree.GetSize());
            for (int i = 0; i < size; i++)
            {
                AssertEquals("key " + i, btree.Search(i));
            }
        }
示例#9
0
 public virtual void Testsearch10()
 {
     NeoDatis.Btree.IBTreeSingleValuePerKey btree = GetBTree(3);
     for (int i = 0; i < 10; i++)
     {
         btree.Insert(i, "key " + i);
     }
     AssertEquals(10, btree.GetSize());
     AssertEquals("key 1", btree.Search(1));
     AssertEquals("key 9", btree.Search(9));
     NeoDatis.Btree.IBTreeNodeOneValuePerKey child3 = (NeoDatis.Btree.IBTreeNodeOneValuePerKey
                                                       )btree.GetRoot().GetChildAt(2, false);
     AssertEquals(4, child3.GetNbKeys());
     AssertEquals(6, child3.GetKeyAt(0));
     AssertEquals(7, child3.GetKeyAt(1));
     AssertEquals(8, child3.GetKeyAt(2));
     AssertEquals(9, child3.GetKeyAt(3));
     AssertEquals(null, child3.GetKeyAt(4));
 }
示例#10
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());
        }
示例#11
0
 public virtual void TestInsert3()
 {
     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");
     btree.Insert(6, "key 6");
     AssertEquals(6, 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));
     AssertEquals("key 6", btree.Search(6));
     AssertEquals(2, btree.GetRoot().GetNbChildren());
     // child 1 should be [1,2]
     NeoDatis.Btree.IBTreeNodeOneValuePerKey child1 = (NeoDatis.Btree.IBTreeNodeOneValuePerKey
                                                       )btree.GetRoot().GetChildAt(0, false);
     AssertEquals(2, child1.GetNbKeys());
     AssertEquals(0, child1.GetNbChildren());
     AssertEquals("key 1", child1.GetKeyAndValueAt(0).GetValue());
     AssertEquals(1, child1.GetKeyAndValueAt(0).GetKey());
     // child 2 should be [4,5,6]
     NeoDatis.Btree.IBTreeNodeOneValuePerKey child2 = (NeoDatis.Btree.IBTreeNodeOneValuePerKey
                                                       )btree.GetRoot().GetChildAt(1, false);
     AssertEquals(3, child2.GetNbKeys());
     AssertEquals(0, child2.GetNbChildren());
     AssertEquals("key 4", child2.GetKeyAndValueAt(0).GetValue());
     AssertEquals("key 5", child2.GetKeyAndValueAt(1).GetValue());
     AssertEquals("key 6", child2.GetKeyAndValueAt(2).GetValue());
     // child 2 should be null
     NeoDatis.Btree.IBTreeNodeOneValuePerKey child3 = (NeoDatis.Btree.IBTreeNodeOneValuePerKey
                                                       )btree.GetRoot().GetChildAt(2, false);
     AssertEquals(null, child3);
 }