/// <summary> /// Method that creates a stack, and implements the Enqueue and DeQueue methods which adds a node, and removes the bottom node /// </summary> public static void QueueWithStack() { StackBuild stack = new StackBuild(new Node(5)); stack.Push(new Node(6)); stack.Push(new Node(7)); stack.Push(new Node(8)); stack.Push(new Node(9)); stack.EnQueue(10); stack.DeQueue(); stack.Print(); Console.ReadKey(); }
/// <summary> /// Removes the bottom node in a stack, as if it were a queue /// </summary> /// <returns>The value of the Node at the bottom</returns> public int DeQueue() { StackBuild temp = new StackBuild(Pop()); while (Top.Next != null) { temp.Push(Pop()); } int hold = Pop().Value; while (temp.Top.Next != null) { Push(temp.Pop()); } return(hold); }