/// <summary> /// Returnerar en lista med alla värden i sökträdet i preorder. /// </summary> public IEnumerable <T> Preorder() { if (_root != null) { return(_root.Preorder()); } else { return(new List <T>()); } }
public IEnumerable <T> Preorder() { List <T> PreList = new List <T>(); if (this._value != null) { PreList.Add(this._value); if (_leftChild != null) { PreList.AddRange(_leftChild.Preorder()); } if (_rightChild != null) { PreList.AddRange(_rightChild.Preorder()); } } return(PreList); }