示例#1
0
        public void OrderStatisticTreeTests_Random_GetRank2()
        {
            Random r = new Random();
            int    n = r.Next(1000000) + 1;

            IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>();

            for (int i = 0; i < n; i++)
            {
                int key = r.Next(int.MaxValue);
                tree.Insert(key, string.Empty);
            }

            var list = tree.TraverseInOrder().ToList();

            for (int i = 0; i < n; i++)
            {
                var actualRank = tree.GetRank((IOrderStatisticTreeNode <int, string>)list[i]);

                Assert.AreEqual(actualRank, i);
            }
        }
        public void OrderStatisticTreeTests_Random_GetRank2()
        {
            Random r = new Random();
            int n = r.Next(1000000) + 1;

            IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>();
            for (int i = 0; i < n; i++)
            {
                int key = r.Next(int.MaxValue);
                tree.Insert(key, string.Empty);
            }

            var list = tree.TraverseInOrder().ToList();

            for (int i = 0; i < n; i++)
            {
                var actualRank = tree.GetRank((IOrderStatisticTreeNode<int, string>)list[i]);

                Assert.AreEqual(actualRank, i);
            }
        }