public int?GetMinValue() { StackElement se = _minStack.Peek(); if (se != null) { return(se.MinStackValue); } else { return(null); } }
public void Push(StackElement stackElement) { int?minValue = this.GetMinValue(); if (minValue != null) { if (stackElement.Value < minValue.Value) { stackElement.MinStackValue = stackElement.Value; } else { stackElement.MinStackValue = minValue.Value; } } else { stackElement.MinStackValue = stackElement.Value; } this._minStack.Push(stackElement); }