?? stack.h
字號:
/*****************************
* _Stack_h_ *
* Stack *
* class template *
* create by si.si *
* 2007.9.25 *
******************************/
#ifndef _Stack_h_
#define _Stack_h_
#include "DList.h"
//name space sisi's data structure
namespace SSDataS
{
/*
*stack class template
*/
template<class T>
class Stack : private DList<T>
{
public:
//constructor and destructor
Stack();
~Stack();
//stack method
/*func Push : bool
*push the new item into this stack
*@param newItem : T the newItem to push into
*@return : bool return true if success
*/
bool Push(T newItem);
/*func Pop : bool
*pop the top item in from this stack
*@param item : T& the item to return the top
* item in this stack
*@return : bool return true if success
*/
bool Pop(T& item);
/*func getLength : int const
*get the length of this stack
*@return : int
*/
int getSLength() const;
/*
*func isSEmpty : bool
*get the EMPTY inf. of this stack
*@return ; bool return true if empty
*/
bool isSEmpty();
/*
*func getTopItem : T const
*get the top item in this stack
*return : T
*/
T getTopItem() const;
};
};
using namespace SSDataS;
template<class T>
Stack<T>::Stack()
{
}
template<class T>
Stack<T>::~Stack()
{
}
template<class T>
bool Stack<T>::Push(const T newItem)
{
return insertAtHead(newItem);
}
template<class T>
bool Stack<T>::Pop(T &item)
{
return removeFromHead(item);
}
template<class T>
int Stack<T>::getSLength() const
{
return getLength();
}
template<class T>
bool Stack<T>::isSEmpty()
{
return isEmpty();
}
template<class T>
T Stack<T>::getTopItem() const
{
return getHeadData();
}
#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -