Exemplo n.º 1
0
        public virtual void TestDeleteInsert100000()
        {
            NeoDatis.Btree.IBTree btree = GetBTree(3);
            int size = 200000;

            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.Delete(i, "key " + i));
            }
            AssertEquals(0, btree.GetSize());
            AssertEquals(1, btree.GetHeight());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
            AssertEquals(0, btree.GetRoot().GetNbChildren());
            for (int i = 0; i < size; i++)
            {
                btree.Insert(size + i, "key " + (i + size));
            }
            for (int i = 0; i < size; i++)
            {
                AssertEquals("key " + (i + size), btree.Delete(i + size, "key " + (i + size)));
            }
            AssertEquals(0, btree.GetSize());
            AssertEquals(1, btree.GetHeight());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
            AssertEquals(0, btree.GetRoot().GetNbChildren());
        }
Exemplo n.º 2
0
 public virtual System.Text.StringBuilder Build(NeoDatis.Btree.IBTree btree, bool
                                                withIds)
 {
     lines = new System.Text.StringBuilder[btree.GetHeight()];
     for (int i = 0; i < btree.GetHeight(); i++)
     {
         lines[i] = new System.Text.StringBuilder();
     }
     BuildDisplay(btree.GetRoot(), 0, 0, "0", withIds);
     BuildRepresentation();
     return(result);
 }
Exemplo n.º 3
0
 /// <exception cref="System.Exception"></exception>
 private void TestDelete(int[] numbers)
 {
     NeoDatis.Btree.IBTree btree = GetBTree(2);
     for (int i = 0; i < numbers.Length; i++)
     {
         btree.Insert(numbers[i], "v " + numbers[i]);
     }
     AssertEquals(numbers.Length, btree.GetSize());
     for (int i = 0; i < numbers.Length; i++)
     {
         AssertEquals("v " + (i + 1), btree.Delete(i + 1, "v " + (i + 1)));
     }
     AssertEquals(0, btree.GetSize());
     AssertEquals(1, btree.GetHeight());
     AssertEquals(0, btree.GetRoot().GetNbKeys());
     AssertEquals(0, btree.GetRoot().GetNbChildren());
 }
Exemplo n.º 4
0
        public virtual void TestDelete1000_3()
        {
            NeoDatis.Btree.IBTree btree = GetBTree(3);
            int size = 1000;

            for (int i = 0; i < size; i++)
            {
                btree.Insert(i, "value " + i);
            }
            AssertEquals(size, btree.GetSize());
            for (int i = size - 1; i >= 0; i--)
            {
                AssertEquals("value " + i, btree.Delete(i, "value " + i));
            }
            AssertEquals(0, btree.GetSize());
            AssertEquals(1, btree.GetHeight());
            AssertEquals(0, btree.GetRoot().GetNbKeys());
            AssertEquals(0, btree.GetRoot().GetNbChildren());
        }