-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
54 lines (45 loc) · 951 Bytes
/
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
#include "header.h"
using namespace std;
#define Data Element<double>
int main()
{
Queue<Data> q;
q.enqueue(Data(1.0));
q.enqueue(Data(2.0));
q.dequeue();
q.dequeue();
q.enqueue(Data(3.0));
q.enqueue(Data(4.0));
q.enqueue(Data(10.0));
q.enqueue(Data(20.0));
for (int i = 0; i < 4; i++)
{
Data e = q.dequeue();
if (e.isValid())
{
cout << e.get() << endl;
}
}
cout << "=======================" << endl;
Stack<Data> s;
s.push(Data(1.0));
s.push(Data(2.0));
s.pop();
s.pop();
s.push(Data(3.0));
Data e = s.peek();
if (e.isValid())
cout << "peeking: " << e.get() << endl;
s.push(Data(4.0));
s.push(Data(10.0));
s.push(Data(20.0));
for (int i = 0; i < 4; i++)
{
Data e = s.pop();
if (e.isValid())
{
cout << e.get() << endl;
}
}
return 0;
}