stack.h

来自「一个可视化的编译器」· C头文件 代码 · 共 51 行

H
51
字号
/// <author> 任晶磊 </author>
/// <update> 2008-3-1 </update>
///	<E-mail> renjinglei@163.com </E-mail>

#ifndef STACK_H
#define STACK_H

#include <stack>
template <typename Type> 
/// <summary>
/// 栈的接口类
/// </summary>
class Stack
{ 
public: 
	void Push(Type elem) 
	{ 
		base.push(elem); 
	}

	Type Top()
	{
		return base.top();
	}

	/// <summary>
	/// 弹出栈定元素
	/// </summary>
	/// <returns>返回弹出的栈定元素,STL stack的pop()方法不返回值</returns>
	Type Pop() 
	{ 
		Type temp = base.top();
		base.pop();
		return temp; 
	} 
	
	int Size() 
	{
		return (int)base.size();
	} 

	bool Empty()
	{
		return base.empty();
	}

private: 
	std::stack<Type> base; 
}; 

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?