-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpila.h
57 lines (45 loc) · 1.13 KB
/
pila.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __PILA_H__
#define __PILA_H__
#if !defined(NULL)
#define NULL 0
#endif
#if !defined(FALSE)
#define FALSE 0
#endif
#if !defined(TRUE)
#define TRUE 1
#endif
typedef struct TNodoPila
{
void* Elem;
struct TNodoPila *Siguiente;
} TNodoPila;
typedef struct
{
TNodoPila *Tope;
int TamanioDato;
} TPila;
/*P_Crear
Pre: P no fue creada.
Post: P creada y vacía. */
void P_Crear(TPila *pP, int TamanioDato);
/*P_Vaciar
Pre: P creada.
Post: P vacía. */
void P_Vaciar(TPila *pP);
/*P_Vacia
Pre: P creada.
Post: Si P está vacía devuelve TRUE, sino FALSE. */
int P_Vacia(TPila P);
/*P_Agregar
Pre: P creada.
Post: E se agregó como Tope de P.
Devuelve FALSE si no pudo agregar E, sino devuelve TRUE.*/
int P_Agregar(TPila *pP, void* pE);
/*P_Sacar
Pre: P creada y no vacia.
Post: Se extrajo de P el tope y se devuelve en E.
Si no pudo extraer el elemento (porque la pila estaba vacía) devuelve FALSE,
sino devuelve TRUE.*/
int P_Sacar(TPila *pP, void* pE);
#endif