public new int Pop() { int value = base.Pop(); if (value == Min()) { s2.Pop(); } return(value); }
private void ShiftStacks() { if (stackOld.IsEmpty()) { while (!stackNew.IsEmpty()) { stackOld.Push(stackNew.Pop()); } } }
public bool Sort() { if (stack.IsEmpty()) { return(false); } while (!stack.IsEmpty()) { int top = stack.Pop(); while (!tempStack.IsEmpty() && tempStack.Peek() > top) { stack.Push(tempStack.Pop()); } tempStack.Push(top); } while (!tempStack.IsEmpty()) { stack.Push(tempStack.Pop()); } return(true); }
public int Pop() { MyStack <int> last = GetLastStack(); if (last == null) { throw new InvalidOperationException(); } int v = last.Pop(); size--; if (size == 0) { stacks.Remove(last); } return(v); }