-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_dll.cpp
More file actions
42 lines (40 loc) · 832 Bytes
/
test_dll.cpp
File metadata and controls
42 lines (40 loc) · 832 Bytes
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
#include "DoublyLinkedList.h"
using Node = DoublyLinkedList<int>::Node;
int main() {
auto dll = DoublyLinkedList<int>();
auto n1 = new Node();
n1->data = 1;
dll.insert(nullptr, n1);
dll.print();
auto n2 = new Node();
n2->data = 2;
dll.insert(nullptr, n2);
dll.print();
auto n3 = new Node();
n3->data = 3;
dll.insert(n2, n3);
dll.print();
auto n4 = new Node();
n4->data = 4;
dll.insert(n1, n4);
dll.print();
dll.remove(n2);
dll.print();
dll.insert(n4, n2);
dll.print();
dll.remove(n3);
dll.print();
dll.insert(n4, n3);
dll.print();
dll.remove(n1);
dll.print();
while (dll.head != nullptr) {
dll.pop_front();
dll.print();
}
delete n1;
delete n2;
delete n3;
delete n4;
return 0;
}