public AVLTreeNode(T value, AVLTreeNode <T> parent, AVLTree <T> tree, string Dpi, Manual_List <string> treelist) { Data = value; Parent = parent; Tree = tree; DPI = Dpi; Treelist = treelist; }
public void AddTo(T value, AVLTreeNode <T> current, string DPI) { if (Root == null) { Root = new AVLTreeNode <T>(value, null, this, DPI, elementos = new Manual_List <string>()); Root.Treelist.AddLast(DPI); return; } if (current.Data.CompareTo(value) == 0) { current.Treelist.AddLast(DPI); return; } if (current.Data.CompareTo(value) < 0) { if (current.Left == null) { current.Left = new AVLTreeNode <T>(value, current, this, DPI, elementos = new Manual_List <string>()); current.Left.Treelist.AddLast(DPI); } else { AddTo(value, current.Left, DPI); } } else { if (current.Right == null) { current.Right = new AVLTreeNode <T>(value, current, this, DPI, elementos = new Manual_List <string>()); current.Right.Treelist.AddLast(DPI); } else { AddTo(value, current.Right, DPI); } } var parent = current; while (parent != null) { if (parent.State != BalanceState.Balanced) { parent.Balance(); } parent = parent.Parent; } }