-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
195 lines (163 loc) · 4.43 KB
/
main.cpp
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
//PARA COMPILAR VIA TERMINAL: g++ sequence.cpp main.cpp -std=c++11 -o programa
#include <iostream>
#include "stack.hpp"
#include "queue.hpp"
#include "deque.hpp"
#include "sequence.cpp"
int main() {
Sequence<int> Seq, Seq2;
int i;
/**
Como os métodos isEmpty(), getSize(), clear(), copy() e swap() já sao usados em outros metodos,
eles não serão testados no main.
**/
//TESTE ADDFIRST
std::cout << "## Teste addFirst: \n";
for (i = 2; i <= 4; i++){
if (!Seq.addFirst(i))
std::cout << "erro ao add no\n";
}
std::cout << "Elementos adicionados com sucesso\n";
//TESTE PRINT
std::cout << "Seq 1:\t";
Seq.print();
//TESTE ADDLAST
std::cout << "\n## Teste addLast():\n";
std::cout << "Seq 1:\t";
Seq.addLast(1);
Seq.addLast(0);
Seq.print();
//TESTE ADD
std::cout << "\n## Teste add():\t(indices iniciam no 0)\n";
std::cout << "Seq 1:\n";
std::cout << "Add posicao 2:\t";
Seq.add(1111, 2);
Seq.print();
std::cout << "Add posicao -1\t";
Seq.add(1111, -1);
Seq.print();
std::cout << "Add posicao 100\t";
Seq.add(1111, 100);
Seq.print();
//TESTE REMOVE FIRST
std::cout << "\n## Teste removeFirst():\n";
std::cout << "Seq 1:\t";
Seq.removeFirst();
Seq.print();
//TESTE REMOVELAST
std::cout << "\n## Teste removeLast():\n";
std::cout << "Seq 1:\t";
Seq.removeLast();
Seq.print();
//TESTE REMOVE
std::cout << "\n## Teste remove():\t(indices iniciam no 0)\n";
std::cout << "Seq 1:\n";
std::cout << "Remover posicao 2:\t";
Seq.remove(2);
Seq.print();
std::cout << "Remover posicao -1\t";
Seq.remove(-1);
Seq.print();
std::cout << "Remover posicao 100\t";
Seq.remove(100);
Seq.print();
//TESTE GETFIRST E GETLAST
std::cout << "\n## Teste getFirst() e getLast:\n";
std::cout << "Primeiro elemento: " << Seq.getFirst() << std::endl;
std::cout << "Ultimo elemento: " << Seq.getLast() << std::endl;
Seq.addFirst(4);
Seq.addFirst(5);
Seq.addFirst(6);
std::cout << "\nNova sequencia:\n";
Seq.print();
//TESTE GET
std::cout << "\n## Teste get():\n";
std::cout << "Posicao 0: " << Seq.get(0) << std::endl;
std::cout << "Posicao 3: " << Seq.get(3) << std::endl;
//TESTE SEARCH
std::cout << "\n## Teste search():\n";
std::cout <<"Busca 5: ";
if (Seq.search(5))
std::cout <<"esta na sequencia\n";
else
std::cout << "nao esta na sequencia\n";
std::cout << "Busca 400: ";
if (Seq.search(400))
std::cout <<"esta na sequencia\n";
else
std::cout << "nao esta na sequencia\n";
//TESTE IS INCREASING
std::cout << "\n## Teste isIncreasing():\n";
if (Seq.isIncreasing())
std::cout << "Seq Eh crescente\n";
else
std::cout << "Seq nao eh crescente\n";
//TESTE IS DECREASING
std::cout << "\n## Teste isDecreasing():\n";
if (Seq.isDecreasing())
std::cout << "Seq eh Decrescente\n";
else
std::cout << "Seq nao eh Decrescente\n";
Seq.addFirst(8);
Seq.addLast(50);
Seq.add(-1, 4);
std::cout << "\nNova sequencia de Teste:\n";
Seq.print();
//TESTE BOUNDS
std::cout << "\n## Teste bounds():\n";
int min, max;
Seq.bounds(min, max);
std::cout << "Valor minimo: " << min << std::endl;
std::cout << "Valor maximo: " << max << std::endl;
/* //TESTE CONSTRUTOR DE CÓPIA
std::cout << "\n## Teste Construtor de Copia:\n";
Sequence<int> Seq3(Seq);
std::cout << "Seq 3:\t";
Seq3.print();
/* //TESTE OPERADOR
std::cout << "\n## Teste Operador = :\n";
Seq2 = Seq;
std::cout << "Seq 2:\t";gmail
Seq2.print();
//TESTE REMOVEFIRST
std::cout << "\n## Teste removeFirst():\n";
std::cout << "Seq 3:\t";
Seq.removeFirst();
Seq.print();
*/
/* //TESTE ISEQUAL
std::cout << "\n## Teste isEqual():\n";
if (Seq.isEqual(Seq3))
std::cout << "Seq1 = Seq3" << std::endl;
else
std::cout << "Seq1 != Seq3" << std::endl;
/* Stack<int> s;
Queue<int> q;
Deque<int> d;
int array[] = { 5, 2, 8, 1, 4, 6, 9, 0, 7, 3 };
for (int i = 0; i < 10; ++i) {
s.push(array[i]);
q.enqueue(array[i]);
d.pushFront(array[i]);
}
// --- print stack
std::cout << "## Stack:\n";
while (!s.isEmpty()) {
std::cout << s.pop() << " ";
}
std::cout << std::endl;
// --- print queue
std::cout << "\n## Queue:\n";
while (!q.isEmpty()) {
std::cout << q.dequeue() << " ";
}
std::cout << std::endl;
// --- print deque
std::cout << "\n## Deque:\n";
while (!d.isEmpty()) {
std::cout << d.popBack() << " ";
}
std::cout << std::endl;
return 0;
*/
}