/// <summary> /// Method finds the beginning of the "Queue" or /// bottom of StackOne /// </summary> /// <returns></returns> public Node Peek() { while (StackOne.Peek() != null) { StackTwo.Push(StackOne.Pop()); } Front = StackTwo.Top; while (StackTwo.Peek() != null) { StackOne.Push(StackTwo.Pop()); } return(Front); }
/// <summary> /// Method uses the Stack Push and Pop methods to emulate FIFO. /// It will move all values from StackOne to StackTwo, pop and store the top /// from StackTwo and then proceed to re-fill StackOne to ensure Queue-Like /// Order /// </summary> /// <returns>Node that is removed</returns> public Node Dequeue() { while (StackOne.Peek() != null) { StackTwo.Push(StackOne.Pop()); } Node popped = StackTwo.Pop(); Front = StackTwo.Top; while (StackTwo.Peek() != null) { StackOne.Push(StackTwo.Pop()); } return(popped); }