手搓的STL模板

· · 个人记录

STL模板(手搓)

队列(queue)

class que{
    private:
        int a[10005],t=-1,w=-1;
    public:
        void clear(){
            w=t;
        }
        bool empty(){
            if(w==t)
                return true;
            return false;
        }
        int size(){
            return w-t;
        }
        void push(int x){
            a[++w]=x;
        }
        void pop(){
            t++;
        }
        int front(){
            return a[t+1];
        }
};

栈(stack)

class sta{
    private:
        int a[10005],t=-1;
    public:
        int top(){
            return a[t];
        }
        void push(int x){
            a[++t]=x;
        }
        int size(){
            return t+1;
        }
        void pop(){
            t--;
        }
        bool empty(){
            return t==-1;
        }
};