コード例 #1
0
        public int?GetMinValue()
        {
            StackElement se = _minStack.Peek();

            if (se != null)
            {
                return(se.MinStackValue);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        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);
        }