Files correlati : Ricompilazione Demo : [ ] Commento : stack.* Aggiunto copy constructor degli TStack tabapp.h Aggiunta #define TTable_application tabutil.cpp Sostitutite varie fexist(n) con n.exist() viswin.cpp Abilitato bottone di stampa solo se presente! git-svn-id: svn://10.65.10.50/trunk@7202 c028cbd2-c16b-5b4b-a496-9718f37d4682
43 lines
639 B
C++
Executable File
43 lines
639 B
C++
Executable File
#include <stack.h>
|
|
|
|
TStack::TStack(int size) : _data(size), _sp(0)
|
|
{ }
|
|
|
|
TStack::TStack(const TStack& stack) : _data(stack._data), _sp(0)
|
|
{ }
|
|
|
|
void TStack::push(const TObject& o)
|
|
{
|
|
_data.add(o, _sp++);
|
|
}
|
|
|
|
void TStack::push(TObject* o)
|
|
{
|
|
_data.add(o, _sp++);
|
|
}
|
|
|
|
TObject& TStack::pop()
|
|
{
|
|
CHECK(_sp > 0, "Stack underflow!");
|
|
return _data[--_sp];
|
|
}
|
|
|
|
TObject& TStack::peek(int depth) const
|
|
{
|
|
CHECKD(depth >= 0 && depth < _sp, "Stack depth error: ", depth);
|
|
return _data[_sp-depth-1];
|
|
}
|
|
|
|
void TStack::destroy()
|
|
{
|
|
_data.destroy();
|
|
_sp = 0;
|
|
}
|
|
|
|
bool TStack::destroy_base()
|
|
{
|
|
if (_sp > 0) _sp--;
|
|
return _data.destroy(0, TRUE);
|
|
}
|
|
|