Repository navigation
Expand file tree
/
Copy pathprimitivas.c
More file actions
95 lines (78 loc) · 1.35 KB
/
Copy pathprimitivas.c
File metadata and controls
95 lines (78 loc) · 1.35 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>
#include <stdlib.h>
#include "primitivas.h"
#include "global.h"
void crear_cola(t_lista *p)
{
*p = NULL;
}
int insertar_cola(t_lista *p, const t_info *d)
{
t_nodo *nue = (t_nodo *)malloc(sizeof(t_nodo));
if(nue == NULL)
return 500;
nue->info = *d;
if(*p == NULL)
{
*p = nue;
nue->sig = nue;
return 1;
}
nue->sig = (*p)->sig;
(*p)->sig = nue;
*p = nue;
return 1;
}
int sacar_de_cola(t_lista *p, t_info *d)
{
t_nodo *aux;
if(*p == NULL)
return 0;
//*d = (*p)->sig->info;
aux = (*p)->sig;
*d = aux->info;
if(aux == *p)
{
free(aux);
*p = NULL;
}
aux = aux->sig;
free(aux);
return 1;
}
int ver_primero_cola(const t_lista *p, t_info *d)
{
if(*p == NULL)
return 500;
*d = (*p)->sig->info;
return 1;
}
int cola_llena(const t_lista *p)
{
//CORREGIR
t_nodo *aux = (t_nodo *)malloc(sizeof(t_nodo));
if(aux == NULL)
return 0;
return 1;
}
int vaciar_cola(t_lista *p)
{
//CORREGIR
if((*p)->sig == NULL)
return 0;
while(*p)
{
t_nodo *aux;
aux = (*p)->sig;
(*p)->sig = aux->sig;
free(aux);
}
return 1;
}
int cola_vacia(const t_lista *p)
{
//CORREGIR
if(*p == NULL)
return 1;
return 0;
}