Example #1
0
        public int pop()
        {
            if (mStack == null)
            {
                return(0);
            }
            MangoNode mangoNode = mStack;

            mStack = mangoNode.next;
            if (mangoNode.oldMax != null)
            {
                max = mangoNode.oldMax;
            }
            return(mangoNode.value);
        }
Example #2
0
        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;
            }
        }