private void addToStack(IAVLTreeNode <T> node) { while (node != null) { this.stack.Push(node); node = node.LeftChild; } }
//public int BalancedFactor => GetHeight(LeftNode) + GetHeight(RightNode); private int GetHeight(IAVLTreeNode <int> node) { if (node == null) { return(-1); } return(Math.Max(GetHeight(node.LeftNode), GetHeight(node.RightNode)) + 1); }
public bool MoveNext() { if (this.pendingNode != null) { this.addToStack(this.pendingNode); this.pendingNode = null; return(this.stack.Count > 0); } if (this.stack.Count > 0) { IAVLTreeNode <T> node = this.stack.Pop(); this.addToStack(node.RightChild); } return(this.stack.Count > 0); }
public AVLTreeNode(T value, IAVLTreeNode <T> parent, IAVLTree <T> tree) { Value = value; Parent = parent; _tree = tree; }
public void Dispose() { this.stack = null; this.rootNode = this.pendingNode = null; }
public AVLTreeEnumerator(IAVLTreeNode <T> node) { this.rootNode = node; this.Reset(); }