campo-sirio/include/stack.cpp
guy e7b77a3e3e assoc.cpp Corretto il metodo is_key
expr.cpp      Migliorata l'efficienza ci compilazione e valutazione
printapp.cpp  Corretti commenti
progind.cpp   Corretta posizione della barra
relation.cpp  Resi maiuscoli i nomi dei campi nei TFiledref
sheet.cpp     Resi accettabili TBrowse_sheet senza campo di ricerca
stack.cpp     Aggiunto metodo peek
strings.cpp   Trasformati alcuni yesnofatal_box in NFHECK
viswin.cpp    Corretto errore di scrittura di __LONDOUBLE


git-svn-id: svn://10.65.10.50/trunk@3468 c028cbd2-c16b-5b4b-a496-9718f37d4682
1996-08-30 14:30:08 +00:00

27 lines
414 B
C++
Executable File

#include <stack.h>
TStack::TStack(int size) : TArray(size), _sp(0)
{}
void TStack::push(const TObject& o)
{
add(o, _sp++);
}
void TStack::push(TObject* o)
{
add(o, _sp++);
}
TObject& TStack::pop()
{
CHECK(_sp > 0, "Stack underflow!");
return (*this)[--_sp];
}
TObject& TStack::peek(int depth) const
{
CHECKD(depth >= 0 && depth < _sp, "Stack depth error: ", depth);
return (*this)[_sp-depth-1];
}