模板 - 栈

STL的栈,可能有一些不需要的信息。
其实用数组实现之后是这个鬼样子。感觉还不如直接用。

struct Stack{
    int st[MAXSIZE];
    int top;
    inline void Clear(){
        top=0;
    }
    inline void Push(int x){
        st[++top]=x;
    }
    inline void Pop(){
        --top;
    }
    inline int Top(){
        return st[top];
    }
    inline int Size(){
        return top;
    }
    inline bool Empty(){
        return !top;
    }
};

猜你喜欢

转载自www.cnblogs.com/Yinku/p/11210635.html