-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDoublyLinkedListClassTest.cpp
More file actions
101 lines (72 loc) · 2.93 KB
/
Copy pathDoublyLinkedListClassTest.cpp
File metadata and controls
101 lines (72 loc) · 2.93 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
#include "clsDblLinkedList.h"
#include <cstdlib>
#include <iostream>
using namespace std;
int main()
{
clsDblLinkedList <int> MyDblLinkedList;
cout << "\nIs Linked List Empty ?: " << MyDblLinkedList.IsEmpty();
cout << "\nLinked List Size: " << MyDblLinkedList.Size() << endl;
cout << "\nAdding Content:\n";
MyDblLinkedList.InsertAtBeginning(5);
MyDblLinkedList.InsertAtBeginning(4);
MyDblLinkedList.InsertAtBeginning(3);
MyDblLinkedList.InsertAtBeginning(2);
MyDblLinkedList.InsertAtBeginning(1);
cout << "\nLinked List Content:\n";
MyDblLinkedList.PrintList();
cout << "\nLinked List Size: " << MyDblLinkedList.Size() << endl;
cout << "\nIs Linked List Empty ?: " << MyDblLinkedList.IsEmpty() << endl;
clsDblLinkedList<int>::Node* N;
N = MyDblLinkedList.GetNode(2);
cout << "\nNode with index 2 value is : " << N->value << endl;
cout << "\nItem(2) value is : " << MyDblLinkedList.GetItem(2) << endl;
cout << "\nAfter Updating Item(2):\n";
MyDblLinkedList.UpdateItem(2, 300);
MyDblLinkedList.PrintList();
MyDblLinkedList.InsertAfter(2, 350);
cout << "\nAfter Inserting 350 after index 3 \n";
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
cout << "\nLinked List Reversed Content:\n";
MyDblLinkedList.Reverse();
MyDblLinkedList.PrintList();
cout << "\nLinked List Size: " << MyDblLinkedList.Size() << endl;
cout << "\nIs Linked List Empty ?: " << MyDblLinkedList.IsEmpty();
clsDblLinkedList<int>::Node* N1 = MyDblLinkedList.Find(2);
if (N1 != NULL)
cout << "\n Node with value " << N1->value << " is Found ^ _ ^ \n";
else
cout << "\n Node Is not found :-(\n";
MyDblLinkedList.InsertAfter(N1, 500);
cout << "\nAfter Inserting 500 after " << N1->value << " :\n";
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
MyDblLinkedList.InsertAtEnd(700);
cout << "\nAfter Inserting 700 at end:\n";
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
clsDblLinkedList<int>::Node* N2 = MyDblLinkedList.Find(4);
MyDblLinkedList.DeleteNode(N2);
cout << "\nAfter Deleting 4:\n";
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
MyDblLinkedList.DeleteFirstNode();
cout << "\nAfter Deleting First Node:\n";
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
cout << "\nAfter Deleting Last Node:\n";
MyDblLinkedList.DeleteLastNode();
MyDblLinkedList.PrintList();
cout << "\nSize: " << MyDblLinkedList.Size() << endl;
cout << "\nAfter Clear Linked List:\n";
MyDblLinkedList.Clear();
MyDblLinkedList.PrintList();
cout << "Size: " << MyDblLinkedList.Size() << endl;
cout << "Is Linked List Empty ?: " << MyDblLinkedList.IsEmpty();
cout << "\n==================================================\n";
cout << " ALL TESTS COMPLETED SUCCESSFULLY \n";
cout << "==================================================\n";
system("pause>0");
return 0;
}