-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist.cpp
65 lines (46 loc) · 1.18 KB
/
list.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
/*****************************************************************
* l i s t . c p p *
* linked list functions *
* *
* started 6/15/98, Karl Kosack (kosack@andrew.cmu.edu) *
*****************************************************************/
#include "list.h"
IsectList::IsectList(void) {
first = NULL;
current = first;
}
IsectList::~IsectList(void){
ListItem *temp;
while (first != NULL && first->next != NULL){
temp = first->next;
delete first;
first = temp;
}
delete first;
first = NULL;
}
void
IsectList::addItem(Isect *item){
ListItem *newitem;
newitem = new ListItem;
newitem->node = item;
newitem->next = first;
first = newitem;
}
bool
IsectList::isEmpty(void){
if (first==NULL) return true;
else return false;
}
void
IsectList::beginIteration(void){
current = first;
}
Isect*
IsectList::getItem(void){
Isect *temp;
if(current == NULL) return NULL;
temp = current->node;
current = current->next;
return temp;
}