-
Notifications
You must be signed in to change notification settings - Fork 0
/
PassengerQueue.cpp
77 lines (67 loc) · 1.21 KB
/
PassengerQueue.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
74
75
76
77
/* PassengerQueue.cpp
*
* Implementation of PassengerQueue class methods
*
* Linh Nguyen (lnguye18)
* Jun 19 2023
*/
#include "PassengerQueue.h"
// constructor
PassengerQueue::PassengerQueue() {
}
/*
* deconstructor
*/
PassengerQueue::~PassengerQueue() {
p_list.clear();
}
/*
* front
* Input:
* Description: return the first element of the list.
* Output:
*/
Passenger PassengerQueue::front() {
return p_list.front();
}
/*
* dequeue
* Input:
* Description: pop the first element out of the list.
* Outpur:
*/
void PassengerQueue::dequeue() {
p_list.pop_front();
}
/*
* enqueue
* Input: new element
* Description: add new element into the list.
* Output:
*/
void PassengerQueue::enqueue(const Passenger &passenger) {
p_list.push_back(passenger);
}
/*
* size
* Input:
* Description: return size of the list.
* Output:
*/
int PassengerQueue::size() {
return p_list.size();
}
/*
* print
* Input: output stream
* Description: print the list.
* Output:
*/
void PassengerQueue::print(std::ostream &output) {
list<Passenger> temp_list;
temp_list = p_list;
while (not temp_list.empty()) {
temp_list.front().print(cout);
temp_list.pop_front();
}
}