public int Pop() { if (count == 0) { throw new Exception("Stack is empty!"); } int v = head.value; head = head.next; count--; if (v == Max()) { maxStack = maxStack.next; } return(v); }
public void Push(int v) { if (count == 0) { head = new p7_1.Node71(v); maxStack = head; count++; } else { head = head.Insert(v); count++; if (v >= maxStack.value) { maxStack = maxStack.Insert(v); } } }