-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathUnsortedList.cpp
More file actions
148 lines (121 loc) · 2.19 KB
/
UnsortedList.cpp
File metadata and controls
148 lines (121 loc) · 2.19 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/*
* UnsortedList.cpp
*/
#include "UnsortedList.h"
UnsortedList::UnsortedList()
{
length = 0;
listData = NULL;
currentPos = NULL;
}
/*UnsortedList::~UnsortedList()
{
node* ptr;
while (listData!=NULL)
{
ptr = listData->next;
delete listData;
listData = ptr;
length--;
}
}*/
void UnsortedList::MakeEmpty()
{
node* ptr;
while (length > 0)
{
ptr = listData->next;
delete listData->nodes;
delete listData;
listData = ptr;
length--;
}
}
bool UnsortedList::IsFull()
{
node* ptr;
ptr = new node;
if ( ptr == NULL )
{
return true;
}
else
{
delete ptr;
return false;
}
}
int UnsortedList::LengthIs()
{
return length;
}
/*void UnsortedList::RetrieveItem(point& retrieve, bool& found)
{
node* location;
location = listData;
found = false;
while( (location != NULL) && !found) {
if (((location->pixel).x == retrieve.x)&&((location->pixel).y == retrieve.y))
{
retrieve = location->pixel;
found = true;
}
else
location = location->next;
}
}*/
void UnsortedList::InsertItem( nodeType* newItem )
{
node* location;
location = new node;
location->nodes = newItem;
location->next = listData;
listData = location;
length++;
}
/*
void UnsortedList::DeleteItem(point item)
{
node* location = listData;
node* tempLocation;
if(((location->pixel).x == item.x)&&((location->pixel).y == item.y))
{
tempLocation = listData; // special case
listData = listData->next;
}
else {
while((!( (((location->next)->pixel).x == item.x)&&(((location->next)->pixel).y == item.y) ))&& ((location->next)!=NULL))
location = location->next;
// delete node at location->next
tempLocation=location->next;
location->next = tempLocation->next;
}
delete tempLocation;
length--;
}
*/
void UnsortedList::ResetList()
{
currentPos = listData;
}
bool UnsortedList::IsLastItem()
{
return(currentPos == NULL);
}
/*
void UnsortedList::GetNextItem(point& item)
{
item = currentPos->pixel;
currentPos = currentPos->next;
}
void UnsortedList::operator=( UnsortedList& copiedList )
{
MakeEmpty();
copiedList.ResetList();
point copy;
while ( !copiedList.IsLastItem() )
{
copiedList.GetNextItem( copy );
InsertItem( copy );
}
}*/