f9b9e70dbd
codeb.c Corretta creazione nome tag delle chiavi isam.h Aggiunta put dei long double relation.cpp Corretta rewrite delle relazioni stack.cpp Aggiunto metodo remove_base stack.h Cambita derivazione da TArray a TObject stdtypes.cpp Aggiunto supporto per chiave di rete stdtypes.h Aggiunta chiamata get_serial_number(const char* ) git-svn-id: svn://10.65.10.50/trunk@4500 c028cbd2-c16b-5b4b-a496-9718f37d4682
32 lines
487 B
C++
Executable File
32 lines
487 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()
|
|
{
|
|
return _data.destroy(0, TRUE);
|
|
}
|