Exemplo n.º 1
0
        public static void Test()
        {
            var test = TreeWithIterator <int, int> .MakeTestTree();

            var it = test.GetIterator();

            while (it.HasNext())
            {
                Console.WriteLine(it.Next());
            }
        }
Exemplo n.º 2
0
        public static TreeWithIterator <int, int> MakeTestTree()
        {
            var tree = new TreeWithIterator <int, int>();

            tree.root = new TreeWithIterator <int, int> .Node()
            {
                Key = 5, Value = 5
            };
            tree.root.Left = new TreeWithIterator <int, int> .Node()
            {
                Key = 3, Value = 3
            };
            tree.root.Left.Left = new TreeWithIterator <int, int> .Node()
            {
                Key = 2, Value = 2
            };
            tree.root.Left.Left.Left = new TreeWithIterator <int, int> .Node()
            {
                Key = 1, Value = 1
            };
            tree.root.Left.Right = new TreeWithIterator <int, int> .Node()
            {
                Key = 4, Value = 4
            };

            tree.root.Right = new TreeWithIterator <int, int> .Node()
            {
                Key = 10, Value = 10
            };
            tree.root.Right.Left = new TreeWithIterator <int, int> .Node()
            {
                Key = 8, Value = 8
            };
            tree.root.Right.Left.Right = new TreeWithIterator <int, int> .Node()
            {
                Key = 9, Value = 9
            };
            tree.root.Right.Right = new TreeWithIterator <int, int> .Node()
            {
                Key = 11, Value = 11
            };

            return(tree);
        }