-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLista.cpp
More file actions
executable file
·126 lines (111 loc) · 3.16 KB
/
Copy pathLista.cpp
File metadata and controls
executable file
·126 lines (111 loc) · 3.16 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Lista.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
/*------------------------------------------------------------------------*/
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
// Lista
Lista::~Lista()
{
ElementoLista *aux=Primera;
while(aux!=NULL)
{
Primera=Primera->Siguiente;
delete(aux);
aux=Primera;
}
}
/*------------------------------------------------------------------------*/
int Lista::Agrega_variable(String valor)
{
ElementoLista *agregado = new ElementoLista(Indice_variable+1,valor);
if (Primera==NULL)
{
Primera=Ultima=agregado;
}
else
{
Ultima->Siguiente=agregado;
Ultima=Ultima->Siguiente;
}
return ++Indice_variable;
}
/*------------------------------------------------------------------------*/
String Lista::Busca_valor(int IDVA)
{
ElementoLista *aux=Primera;
String Valor=NULL;
while(aux!=NULL)
{
if (aux->IDVA==IDVA) {Valor=aux->Valor;break;}
aux=aux->Siguiente;
}
return Valor;
}
/*------------------------------------------------------------------------*/
bool Lista::Cambia_valor_elemento_lista(int IDVA,String valor)
{
ElementoLista *aux=Primera;
bool Res=false;
while(aux!=NULL)
{
if (aux->IDVA==IDVA) {aux->Valor=valor;Res=true;break;}
aux=aux->Siguiente;
}
return Res;
}
/*------------------------------------------------------------------------*/
bool Lista::Existe_variable_Lista(int IDVA)
{
ElementoLista *aux=Primera;
bool Res=false;
while(aux!=NULL)
{
if (aux->IDVA==IDVA) {Res=true;break;}
aux=aux->Siguiente;
}
return Res;
}
/*------------------------------------------------------------------------*/
bool Lista::Borra_elemento_lista(int idva)
{
ElementoLista *aux=Primera;
ElementoLista *aux2;
bool Res=false;
if(Primera->IDVA==idva)
{
aux=Primera->Siguiente;
delete(Primera);
Primera=aux;
Res=true;
}
if(Ultima->IDVA==idva)
{
while (aux->Siguiente!=Ultima) aux=aux->Siguiente;
delete(Ultima);
Ultima=aux;
Ultima->Siguiente=NULL;
Res=true;
}
if (Res==false)
{
while(aux->Siguiente!=NULL)
{
if (aux->Siguiente->IDVA==idva)
{
aux2=aux->Siguiente;
aux->Siguiente=aux->Siguiente->Siguiente;
delete(aux2);
Res=true;
break;
}
aux=aux->Siguiente;
}
}
return Res;
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////