public int pop() { if (mStack == null) { return(0); } MangoNode mangoNode = mStack; mStack = mangoNode.next; if (mangoNode.oldMax != null) { max = mangoNode.oldMax; } return(mangoNode.value); }
public void Push(int n) { MangoNode newNode = new MangoNode(); newNode.value = n; if (mStack == null) { mStack = newNode; } else { newNode.next = mStack; mStack = newNode; } if (max == null || newNode.value > max.value) { newNode.oldMax = max; max = newNode; } }