Beispiel #1
0
        public void DeleteNonExistingNode()
        {
            var btree = new BTree <int, int>(Degree);

            for (int i = 0; i < this.testKeyData.Length; i++)
            {
                this.InsertTestData(btree, i);
            }

            btree.Delete(99999);
            TreeValidation.ValidateTree(btree.Root, Degree, this.testKeyData.ToArray());
        }
Beispiel #2
0
        public int DeleteNodes()
        {
            var btree = new BTree <int, int>(Degree);

            for (int i = 0; i < this.testKeyData.Length; i++)
            {
                this.InsertTestData(btree, i);
            }

            for (int i = 0; i < this.testKeyData.Length; i++)
            {
                btree.Delete(this.testKeyData[i]);
                TreeValidation.ValidateTree(btree.Root, Degree, this.testKeyData.Skip(i + 1).ToArray());
            }

            return(btree.Height);//1
        }
Beispiel #3
0
        public void DeleteNodeBackwards()
        {
            var btree = new BTree <int, int>(Degree);

            for (int i = 0; i < this.testKeyData.Length; i++)
            {
                this.InsertTestData(btree, i);
            }

            for (int i = this.testKeyData.Length - 1; i > 0; i--)
            {
                btree.Delete(this.testKeyData[i]);
                TreeValidation.ValidateTree(btree.Root, Degree, this.testKeyData.Take(i).ToArray());
            }

            Assert.AreEqual(1, btree.Height);
        }
Beispiel #4
0
 private void InsertTestDataAndValidateTree(BTree <int, int> btree, int testDataIndex)
 {
     btree.Insert(this.testKeyData[testDataIndex], this.testPointerData[testDataIndex]);
     TreeValidation.ValidateTree(btree.Root, Degree, this.testKeyData.Take(testDataIndex + 1).ToArray());
 }