コード例 #1
0
        // ************************************************************************
        /// This dump the tree in a more visual and easy way to see. Where each item is tabbed according to its depth.
        /// Each line is an item. The first line is the last item and so on.
        /// If you look on the side, the tree will look like normal. I prefer using this one instead of DumpVisual2.
        public void DumpVisual(string title = null)
        {
            if (title == null)
            {
                title = Name;
            }

            // int maxLevel = GetMaxLevel();
            int itemWidth = 5;

            AvlNode <T> node = GetLastNode();

            Debug.Print($">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Tree Visual Dump Start '{title}' (First node is at the bottom and last node just below this line)");

            if (Count > 256)
            {
                Debug.Print("Too much items (>256)...");
            }
            else
            {
                while (node != null)
                {
                    int nodeHeight = node.GetHeight() * itemWidth;
                    Debug.Print($"{new string(' ', nodeHeight)}{node.Item}({node.Balance})");
                    node = node.GetPreviousNode();
                }
            }
            Debug.Print($">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Tree Visual Dump End '{title}'");
        }
コード例 #2
0
        // ******************************************************************
        public bool MoveNext()
        {
            if (_current == null)
            {
                _current = _avlTree.GetLastNode();
            }
            else
            {
                _current = _current.GetPreviousNode();
            }

            if (_current == null)             // Should check for an empty tree too :-)
            {
                return(false);
            }

            return(true);
        }