e298ca818d
Files correlati : omnia0.exe Ricompilazione Demo : [ ] Commento : Prima release Acqua Omnia git-svn-id: svn://10.65.10.50/trunk@11726 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);
|
|
}
|
|
|