Professional Documents
Culture Documents
Se considera o reprezentare a stivelor bazata pe liste inlantuite. Accesele se vor face prin
capatul din fata al listei.
Operatiile push si pop sunt atunci realizate cu operatiile ins_in_fata() respectiv
sterge_prim() de la liste inlantuite, iar operatia top() prin primul().
TEMA DE REALIZAT
//--------------------------------------------------------
// F i s i e r u l s t i v a . h
//--------------------------------------------------------
#ifndef __STIVA_H_
#define __STIVA_H_
#include "lista.h"
//--------------------------------------------------------
// F i s i e r u l s t i v a . c
//--------------------------------------------------------
#include "stiva.h"
#include "lista.h"
STIVA news()
{
return (STIVA)newl();
}
//--------------------------------------------------------
STIVA push(STIVA s,DATA x)
{
return ins_in_fata((LISTA)s,x);
}
//---------------------------------------------------------
STIVA pop(STIVA s)
{
return (STIVA) sterge_prim((LISTA)s);
}
//---------------------------------------------------------
DATA top(STIVA s)
{
return emptys(s)?ABSENT : primul(LISTA)s);
}
//---------------------------------------------------------
STIVA toppop(STIVA s, DATA *val)
{
*val=top(s);
return pop(s);
}
//---------------------------------------------------------
LOGIC emptys( STIVA s)
{
return este_vida((LISTA)s);
}
//---------------------------------------------------------
LOGIC fulls(STIVA s)
{
return este_plina((LISTA)s);
}
//---------------------------------------------------------
void destroys(STIVA s)
{
destroy((LISTA)s);
}