00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _NPT_STACK_H_
00011 #define _NPT_STACK_H_
00012
00013
00014
00015
00016 #include "NptResults.h"
00017 #include "NptTypes.h"
00018 #include "NptList.h"
00019
00020
00021
00022
00023 template <typename T>
00024 class NPT_Stack : public NPT_List<T>
00025 {
00026 public:
00027
00028 NPT_Result Push(const T& value) {
00029 return Add(value);
00030 }
00031
00032 NPT_Result Peek(T& value) {
00033
00034
00035 if (this->m_ItemCount == 0) return NPT_ERROR_NO_SUCH_ITEM;
00036 value = this->m_Tail->m_Data;
00037 return NPT_SUCCESS;
00038 }
00039
00040 NPT_Result Pop(T& value) {
00041
00042
00043 if (this->m_ItemCount == 0) return NPT_ERROR_NO_SUCH_ITEM;
00044 typename NPT_List<T>::Iterator tail = this->GetLastItem();
00045 value = *tail;
00046 return this->Erase(tail);
00047 }
00048 };
00049
00050 #endif // _NPT_STACK_H_