Пример #1
0
        public void Fun()
        {
            var tree = new RedBlackTree <int>();

            tree.AddNode(10);
            tree.AddNode(5);
            tree.AddNode(15);
            tree.AddNode(77);

            Assert.IsTrue(tree.Validate());
            Assert.IsTrue(VerifyTree(tree,
                                     "            10B",
                                     "      5B            15B",
                                     "   -      -       -      77R",
                                     " -   -  -   -   -   -   -   - "));

            tree.AddPair(20, 25);
            Assert.IsTrue(tree.Validate());
            Assert.IsTrue(VerifyTree(tree,
                                     "            10B",
                                     "      5B            20R",
                                     "   -      -      15B     77B",
                                     " -   -  -   -   -   -  25R  - "));

            tree.AddPair(27, 29);
            Assert.IsTrue(tree.Validate());
            Assert.IsTrue(VerifyTree(tree,
                                     "            20B",
                                     "     10R            27R",
                                     "   5B    15B     25B     77B",
                                     " -   -  -   -   -   -  29R  - "));
        }