// Push element x to the back of queue. public void Push(int x) { PushStack.Push(x); PopStack.Clear(); foreach (var item in PushStack.ToArray()) { PopStack.Push(item); } }
// Removes the element from front of queue. public void Pop() { PopStack.Pop(); PushStack.Clear(); foreach (var item in PopStack) { PushStack.Push(item); } }
public void Enqueue(T node) { FillPopStack(PopStack, PushStack); PushStack.Push(node); }