Esempio n. 1
0
        public void OrderStatisticTreeTests_GetRank()
        {
            IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>();

            var actualRank = tree.GetRank(null);

            Assert.IsTrue(actualRank == -1);
        }
Esempio n. 2
0
        public void OrderStatisticTreeTests_GetRank()
        {
            IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>();

            var actualRank = tree.GetRank(null);

            Assert.IsTrue(actualRank == -1);
        }
Esempio n. 3
0
        public void OrderStatisticTreeTests_GetRank2()
        {
            IOrderStatisticTree <int, string> tree = new OrderStatisticTree <int, string>();

            tree.Insert(10, "John");
            tree.Insert(5, "Clark");
            var node = tree.Insert(13, "Pitty");

            tree.Insert(17, "Lilly");
            tree.Insert(8, "Jack");
            tree.Insert(0, "Lui");
            tree.Insert(16, "Petr");

            var actualRank = tree.GetRank((IOrderStatisticTreeNode <int, string>)node);

            Assert.IsTrue(actualRank == 4);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
        public void OrderStatisticTreeTests_GetRank2()
        {
            IOrderStatisticTree<int, string> tree = new OrderStatisticTree<int, string>();
            tree.Insert(10, "John");
            tree.Insert(5, "Clark");
            var node = tree.Insert(13, "Pitty");
            tree.Insert(17, "Lilly");
            tree.Insert(8, "Jack");
            tree.Insert(0, "Lui");
            tree.Insert(16, "Petr");

            var actualRank = tree.GetRank((IOrderStatisticTreeNode<int, string>)node);

            Assert.IsTrue(actualRank == 4);
        }
Esempio n. 6
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);
            }
        }