Files
envi-code/SourceCode/Code2026/inc/AdsXRx/DStack.h
T
2026-09-28 15:28:50 +08:00

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