//-------------------------------------------------------------------------------------------------------+ // Copyright (C), 1998-2007, SH Software Co. Ltd. // = FileName : DStack 模板类 // = Version : ver2.0 // = Author : zjq // = CreateDate : 2002-09-09 // = Description: DStack 声明 // = Maintainers: // //-------------------------------------------------------------------------------------------------------+ #ifndef _DSTACK_H_ #define _DSTACK_H_ #ifndef _DLIST_H_ #include "DList.h" #endif template class DStack : public DList< R > { public: DStack(int dFlag = 0); void Push(R *dat); R * Pop(); R * Top(); }; template DStack::DStack(int dFlag) : DList (dFlag) { } template void DStack::Push(R *dat) { this->MoveEnd(); this->Insert(dat); } template R* DStack::Pop() { R* res = this->Tail(); if(this->tail != NULL) { this->tail->data = NULL; } if(this->Length()) { this->Remove(this->Length() - 1); } return res; } template R* DStack::Top() { return this->Tail(); } #endif