跳到正文

个人记录

手搓的STL模板

Wind1123约 1 分钟
原文
文章信息与版本

文章信息

发布
2023年6月22日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 1 分钟

版本

  1. v1当前

STL模板(手搓)

队列(queue)

C++
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)

C++
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;
		}
};
原文
存档评论3 条抓取于