Пример #1
0
        // 返回栈顶元素
        // return:
        //      返回ReversePolishItem对象
        public ReversePolishItem Peek()
        {
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];

            return(oTemp);
        }
Пример #2
0
        // pop一个对象
        // return:
        //		ReversePolishItem对象
        public ReversePolishItem Pop()
        {
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];

            this.RemoveAt(this.Count - 1);

            //可能返回空,调用者错用了类型,应在调用处做判断。
            return(oTemp);
        }
Пример #3
0
        // pop一个对象,只返回节点
        // return:
        //		node节点
        public XmlNode PopNode()
        {
            //栈为空,抛出StackUnderflowException异常
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];

            this.RemoveAt(this.Count - 1);

            //可能返回空,调用者错用了类型,应在调用处做判断。
            return(oTemp.m_node);
        }
Пример #4
0
        // 返回栈顶元素
        // return:
        //      返回ReversePolishItem对象
        public ReversePolishItem Peek()
        {
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];
            return oTemp;
        }
Пример #5
0
        // pop一个对象
        // return:
        //		ReversePolishItem对象
        public ReversePolishItem Pop()
        {
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];
            this.RemoveAt(this.Count - 1);

            //可能返回空,调用者错用了类型,应在调用处做判断。
            return oTemp;
        }
Пример #6
0
        // pop一个对象,只返回节点
        // return:
        //		node节点
        public XmlElement PopNode()
        {
            //栈为空,抛出StackUnderflowException异常
            if (this.Count == 0)
            {
                StackUnderflowException ex = new StackUnderflowException("Pop前,堆栈已经空");
                throw (ex);
            }

            ReversePolishItem oTemp = (ReversePolishItem)this[this.Count - 1];
            this.RemoveAt(this.Count - 1);

            //可能返回空,调用者错用了类型,应在调用处做判断。
            return oTemp.m_node;
        }