public int Pop() { if (this._head == null) { throw new Exception("Stack is empty"); } int returnValue = this._head.Data; this._head = this._head.Next; this.Count--; return(returnValue); }
public void Push(int val) { var newNode = new MaxStackNode(val); if (this._head == null) { newNode.Max = val; this._head = newNode; this.Count++; return; } int max = System.Math.Max(val, this._head.Max); newNode.Next = _head; newNode.Max = max; _head = newNode; this.Count++; }