-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
73 lines (58 loc) · 1.67 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
/*
--------------------------------------------------------------------
* Name: Stan Turovsky
* Class: Advanced C++
* Files: main.cpp, LinkedList.cpp, LinkedList.h, Node.h
* Purpose: Test program for the LinkedList class
* -Nodes are added from different directions, then counted and listed
* -Duplicates are found and removed, then nodes are counted again
* -Nodes are then searched for a number twice
* to makes sure no duplicates are left
--------------------------------------------------------------------
*/
// Preprocessor directives
#include "LinkedList.h"
#include <iostream>
using namespace std;
int main() // main function
{
LinkedList list;
if (list.isEmpty())
cout << "List is empty" << endl;
else
cout << "List contains data" << endl;
list.addBack(1);
list.addBack(4);
list.addBack(4);
list.addFront(2);
list.addFront(2);
list.addBack(3);
list.addFront(3);
cout << "Node count: " << list.countNodes() << endl;
if (list.isEmpty())
cout << "List is empty" << endl;
else
cout << "List contains data" << endl;
list.display();
cout << "Removing duplicates" << endl;
list.removeDuplicates();
cout << "Node count: " << list.countNodes() << endl;
list.display();
Node *node = list.find(4);
if (node == nullptr)
cout << "Did not find 4." << endl;
else
cout << "Found 4." << endl;
node = list.findAgain(4);
if (node == nullptr)
cout << "Did not find 4 more than once." << endl;
else
cout << "Found 4 more than once." << endl;
//list.removeBack();
//list.display();
//list.removeFront();
list.display();
// Leave this stuff at the end.
cout << endl;
return 0;
}