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