-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtellerLine.cpp
More file actions
48 lines (44 loc) · 793 Bytes
/
tellerLine.cpp
File metadata and controls
48 lines (44 loc) · 793 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
43
44
45
46
47
48
#include"tellerLine.h"
#include<iostream>
lineNode::lineNode(Event *event) {
this->event = event;
this->next = 0;
}
lineNode::~lineNode() {
}
tellerLine::tellerLine() {
length = 0;
this->head = 0;
}
tellerLine::~tellerLine() {
}
void tellerLine::add(Event *event) {
length++;
if (head == 0)
head = new lineNode(event);
else {
lineNode *cursor = head;
while (cursor->next != 0) {
cursor = cursor->next;
}
cursor->next = new lineNode(event);
}
}
Event *tellerLine::pop() {
if (head == 0)
return 0;
length--;
lineNode* temp = head;
head = temp->next;
return temp->event;
}
void tellerLine::printQueue() {
if (head == 0) {
return;
}
lineNode *cursor = head;
while (cursor != 0) {
std::cout << cursor->event->time << std::endl;
cursor = cursor->next;
}
}