/// <summary> /// Enumerates the BST's contents using a specified traversal method. /// </summary> /// <param name="traversalMethod">The type of traversal to perform.</param> /// <returns>An enumerator that provides access to the BST's elements using a specified traversal technique.</returns> public virtual IEnumerator <T> GetEnumerator(TraversalMethod traversalMethod) { // The traversal approaches are defined as public properties in the BST class... // This method simply returns the appropriate property. switch (traversalMethod) { case TraversalMethod.Preorder: return(Preorder.GetEnumerator()); case TraversalMethod.Inorder: return(Inorder.GetEnumerator()); default: return(Postorder.GetEnumerator()); } }
public IEnumerator <T> GetEnumerator(TraversalMethod TraversalMethod) { // The traversal approaches are defined as public properties in the BST class... // This method simply returns the appropriate property. if (TraversalMethod == TraversalMethod.Preorder) { return(Preorder.GetEnumerator()); } else if (TraversalMethod == TraversalMethod.Inorder) { return(Inorder.GetEnumerator()); } else { return(Postorder.GetEnumerator()); } }
/// <summary></summary> public IEnumerator <BinaryTreeNode <T> > GetEnumerator(TraversalMethod method) { switch (method) { case TraversalMethod.Postorder: return(Postorder.GetEnumerator()); case TraversalMethod.Inorder: return(Inorder.GetEnumerator()); case TraversalMethod.Levelorder: return(Levelorder.GetEnumerator()); case TraversalMethod.Preorder: default: return(Preorder.GetEnumerator()); } }
/// <summary></summary> public IEnumerator <TreeNode <T> > GetEnumerator(TraversalMethod method) { switch (method) { case TraversalMethod.Postorder: return(Postorder.GetEnumerator()); case TraversalMethod.Inorder: return(Inorder.GetEnumerator()); case TraversalMethod.Levelorder: return(Levelorder.GetEnumerator()); case TraversalMethod.Children: return(this._children.GetEnumerator()); case TraversalMethod.Path: return(Path.GetEnumerator()); case TraversalMethod.Preorder: default: return(Preorder.GetEnumerator()); } }