campo-sirio/include/stack.cpp
guy b86fbf2f4c sheet.cpp Cambiato nome da get_focus_id in low_get_focus_id
stack.cpp   Corretto aggiornamento dello stack pointer
strings.*   Aggiunto nuovo tipo di get alle TToken_string


git-svn-id: svn://10.65.10.50/trunk@6588 c028cbd2-c16b-5b4b-a496-9718f37d4682
1998-05-04 08:12:15 +00:00

33 lines
509 B
C++
Executable File

#include <stack.h>
TStack::TStack(int size) : _data(size), _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];
}
bool TStack::destroy_base()
{
if (_sp > 0) _sp--;
return _data.destroy(0, TRUE);
}