-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestSNode.C
More file actions
executable file
·77 lines (65 loc) · 1.56 KB
/
TestSNode.C
File metadata and controls
executable file
·77 lines (65 loc) · 1.56 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
#include <iostream>
#include "ListUtils.H"
using namespace std;
void printSNode(SNode<int> * node)
{
cout<<node->getData()<<" ";
}
void imprimirLista(SNode<int> & lista)
{
SNode<int> * aux = &lista;
aux = lista.getNext();
while(aux != &lista)
{
cout<<aux->getData()<<" ";
aux = aux->getNext();
}
cout<<endl;
}
int main()
{
//prueba del constructor por omision
SNode<int> node;
SNode<int> * aux = new SNode<int>;
cout<<"Valores por omision"<<endl;
printSNode(&node);cout<<endl;
printSNode(aux);cout<<endl;
//constructores por copia
SNode<int> node1(10);
SNode<int> * aux1 = new SNode<int>(20);
cout<<"Valores por copia"<<endl;
printSNode(&node1);cout<<endl;
printSNode(aux1);cout<<endl;
//insertamos elementos en una lista simple
SNode<int> lista;
for(int i = 0; i < 10 ; i++)
{
lista.insertNext(i);
}
cout<<"Valores de la lista"<<endl;
imprimirLista(lista);
//insertamos elementos en una lista simple de manera ordenada
SNode<int> listaOrdenada;
for(int i = 0; i < 10 ; i++)
{
listaOrdenada.orderedInsertion(i);
}
cout<<"Valores de lista Ordenada"<<endl;
imprimirLista(listaOrdenada);
//utilizamos el iterador sobre nodo
cout<<"Valores lista ordenada usando iterador"<<endl;
for(SNode<int>::Iterator it(&listaOrdenada); it.hasCurrent(); it.next())
{
cout<<it.getCurrent()->getData()<<" ";
}
cout<<endl;
cout<<"Valores lista ordenada"<<endl;
simpleSort(lista);
//quickSort(lista);
imprimirLista(lista);
cout<<"Valores minimo de la lista"<<endl;
cout<<searchMin(&lista)<<endl;
delete aux;
delete aux1;
return 0;
}