コード例 #1
0
        public void OS_SelectTest()
        {
            RedBlackTreeWithIndexAccess tree = new RedBlackTreeWithIndexAccess();
            int NUMBER = 40;

            //int TEST_NUM = 8;
            for (int i = 0; i < NUMBER; i++)
            {
                tree.RB_Insert(i);
            }

            Assert.AreEqual(NUMBER, tree.Count);
            //Trace.WriteLine( "______________________________" );

            try
            {
                //Trace.WriteLine( "________delete 8______________________" );
                tree.RB_Delete(8);
                //Trace.WriteLine( "________delete 9______________________" );
                tree.RB_Delete(9);
                //Trace.WriteLine( "________delete 10______________________" );
                tree.RB_Delete(10);
                //Trace.WriteLine( "________delete 11______________________" );
                tree.RB_Delete(11);
                //Trace.WriteLine( "________delete 12______________________" );
                tree.RB_Delete(12);
                //Trace.WriteLine( "________delete 13______________________" );
                tree.RB_Delete(13);
                //Trace.WriteLine( "________delete 14______________________" );
                tree.RB_Delete(14);
                //Trace.WriteLine( "______________________________" );
                //tree.InorderPrint();
                tree.RB_Delete(15);
                for (int j = 0; j < 32; j++)
                {
                    tree.OS_Select(j);
                    //Assert.AreEqual( i, found );
                }
            }
            catch (InvalidCastException ex)
            {
                Trace.WriteLine(ex.Message);
                Trace.WriteLine("______________________________");
                tree.InorderPrint();
                Trace.WriteLine("tree.Count: " + tree.Count);
                throw ex;
            }
        }