66 lines
1.1 KiB
C++
66 lines
1.1 KiB
C++
//-------------------------------------------------------------------------------------------------------+
|
|
// 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 R> class DStack : public DList< R >
|
|
{
|
|
public:
|
|
DStack(int dFlag = 0);
|
|
|
|
void Push(R *dat);
|
|
|
|
R * Pop();
|
|
R * Top();
|
|
};
|
|
|
|
template<class R>
|
|
DStack<R>::DStack(int dFlag)
|
|
: DList<R> (dFlag)
|
|
{
|
|
|
|
}
|
|
|
|
template<class R>
|
|
void DStack<R>::Push(R *dat)
|
|
{
|
|
this->MoveEnd();
|
|
this->Insert(dat);
|
|
}
|
|
|
|
template<class R>
|
|
R* DStack<R>::Pop()
|
|
{
|
|
R* res = this->Tail();
|
|
|
|
if(this->tail != NULL)
|
|
{
|
|
this->tail->data = NULL;
|
|
}
|
|
|
|
if(this->Length())
|
|
{
|
|
this->Remove(this->Length() - 1);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
template<class R>
|
|
R* DStack<R>::Top()
|
|
{
|
|
return this->Tail();
|
|
}
|
|
#endif
|