public void Push(int value) { if (_stack.Count == 0) { _stack.Push(value); return; } _bufferStack = new SousStack(); while (_stack.Count > 0) { if (_stack.TopMost() < value) { _bufferStack.Push(_stack.TopMost()); _stack.Pop(); } } _stack.Push(value); if (_bufferStack.Count > 0) { _stack.Push(_bufferStack.TopMost()); _bufferStack.Pop(); } }
private void PushToPopStack() { _popStack = new SousStack(); while (_pushStack.Count > 0) { _popStack.Push(_popStack.TopMost()); _popStack.Pop(); } }