Esempio n. 1
0
        public void OS_Rank_AfterDeletingTest()
        {
            RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess();
            int NUMBER = 1000;
            int HALF   = NUMBER / 2;

            for (int i = 0; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }
            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Delete(i);
            }

            for (int i = 0; i < HALF; i++)
            {
                Assert.AreEqual(i, tree.OS_Rank(i));
            }

            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }
            for (int i = 0; i < NUMBER; i++)
            {
                Assert.AreEqual(i, tree.OS_Rank(i));
            }
        }
Esempio n. 2
0
        public void InsertingAfterDeletingTest1()
        {
            RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess();
            int NUMBER = 6;
            int HALF   = NUMBER / 2;

            for (int i = 0; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }
            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Delete(i);
            }

            int test = tree.SearchForIndex(4);

            if (test.Equals(4))
            {
                Assert.Fail("test.Key == 4");
            }
            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }

            //RBNode testNode = tree.GetMinimum();
            //Assert.AreEqual( 0, testNode.Key );
            for (int i = 0; i < NUMBER; i++)
            {
                Assert.AreEqual(i, tree.OS_Rank(i));
                //testNode = tree.GetSuccessor( testNode );
            }
        }
Esempio n. 3
0
        public void InsertingAfterDeletingTest1000()
        {
            RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess();
            int NUMBER = 1000;
            int HALF   = NUMBER / 2;

            for (int i = 0; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }
            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Delete(i);
            }
            for (int i = HALF; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }

            //RBNode testNode = tree.GetMinimum();
            //Assert.AreEqual( 0, testNode.Key );
            for (int i = 0; i < NUMBER; i++)
            {
                Assert.AreEqual(i, tree.OS_Rank(i));
                //testNode = tree.GetSuccessor( testNode );
            }
        }
Esempio n. 4
0
        public void OS_Rank_Test()
        {
            RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess();

            for (int i = 0; i < 1000; i++)
            {
                tree.RB_Insert(i);
            }
            for (int i = 0; i < 1000; i++)
            {
                Assert.AreEqual(i, tree.OS_Rank(i));
            }
        }