forked from teddypee/dsa555-w18
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab3tester.cpp
More file actions
117 lines (106 loc) · 2.18 KB
/
lab3tester.cpp
File metadata and controls
117 lines (106 loc) · 2.18 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
/************************************************************/
/* Lab 3 tester */
/* To compile: */
/* g++ lab3tester.cpp -std=c++0x */
/* To run: */
/* ./a.out */
/************************************************************/
#include "lab3.h"
#include <iostream>
int main(void){
DList<int> regular;
Sentinel<int> sentinel;
std::cout << "testing regular doubly linked list" << std::endl;
for(int i=0;i<3;i++){
regular.push_front(i);
regular.print();
}
regular.reversePrint();
for(int i=3;i<6;i++){
regular.push_back(i);
regular.print();
}
regular.reversePrint();
for(int i=0;i<7;i++){
if(i%2){
regular.pop_front();
}
else{
regular.pop_back();
}
regular.print();
}
regular.reversePrint();
for(int i=0;i<3;i++){
regular.push_back(i);
regular.print();
}
regular.reversePrint();
for(int i=3;i<6;i++){
regular.push_front(i);
regular.print();
}
regular.reversePrint();
for(int i=0;i<7;i++){
if(i%2==0){
regular.pop_front();
}
else{
regular.pop_back();
}
regular.print();
}
regular.reversePrint();
for(int i=0;i<3;i++){
regular.push_front(i);
regular.print();
}
regular.reversePrint();
std::cout << "testing sentinel list" << std::endl;
for(int i=0;i<3;i++){
sentinel.push_front(i);
sentinel.print();
}
sentinel.reversePrint();
for(int i=3;i<6;i++){
sentinel.push_back(i);
sentinel.print();
}
sentinel.reversePrint();
for(int i=0;i<7;i++){
if(i%2){
sentinel.pop_front();
}
else{
sentinel.pop_back();
}
sentinel.print();
}
sentinel.reversePrint();
for(int i=0;i<3;i++){
sentinel.push_back(i);
sentinel.print();
}
sentinel.reversePrint();
for(int i=3;i<6;i++){
sentinel.push_front(i);
sentinel.print();
}
sentinel.reversePrint();
for(int i=0;i<7;i++){
if(i%2==0){
sentinel.pop_front();
}
else{
sentinel.pop_back();
}
sentinel.print();
}
sentinel.reversePrint();
for(int i=0;i<3;i++){
sentinel.push_front(i);
sentinel.print();
}
sentinel.reversePrint();
return 0;
}