📄 tc3d_stack.h
字号:
/**
* Comet 3D Engine file (c) 2007 - 2008 Tianjie Wei, THSystems Research Group
*
* Released under BSD license, please refer to license.txt for more information
*/
#ifndef _TC3D_STACK_H_
#define _TC3D_STACK_H_
#include "TC3D_Array.h"
namespace C3D
{
namespace Util
{
/**
* Stack class template
*
* @Author Tianjie (James) Wei
* @Version 3.0
*/
template < class T, class TAlloc = TC3D_Allocator<T> >
class TC3D_Stack
{
protected:
TC3D_Array<T, TAlloc> tStack;
TC3D_S32 tSP;
public:
/**
* Class constructor
*
* @param none
*/
TC3D_Stack()
{
tSP = 0;
}
/**
* Puts an item into the stack
*
* @param data pointer to the data
* @return none
*/
virtual TC3D_Void Push(const T &item)
{
tStack.Push_Back(item);
tSP++;
}
/**
* Gets an item from top of the stack
*
* @param none
* @return item from the stackk
*/
virtual T Pop() const
{
MC3D_DEBUG_ASSERT(tSP > 0 || tSP < tStack.Size());
T item = tStack[--tSP];
tStack.Pop_Back();
return item;
}
/**
* Looks at the top of the stack
*
* @param none
* @return reference to the item on top of the stack
*/
virtual const T &Peek() const
{
MC3D_DEBUG_ASSERT(tSP >= 0 || tSP < tStack.Size());
return tStack[tSP];
}
};
};
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -