-
Notifications
You must be signed in to change notification settings - Fork 1
/
Queue.cpp
54 lines (44 loc) · 1007 Bytes
/
Queue.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
/**************************************************************************
** Code written by Hesam Gholami.
**
** Email: hesamgholami@yahoo.com
** Website: http://hesam.org
**
** This file created in 12.
**************************************************************************/
#include "Queue.hpp"
Queue::Queue(QObject *parent) : QObject(parent)
{
}
void Queue::addTruck(DumpTruck *truck)
{
this->queue.enqueue(truck);
}
DumpTruck *Queue::getNextTruck()
{
if(this->queue.isEmpty()) {
// Queue is empty
return nullptr;
}
return this->queue.dequeue();
}
QString Queue::getString() const
{
if(this->queue.isEmpty()) {
// Queue is empty
return "";
}
QString strResult;
foreach (auto truck, this->queue) {
strResult += truck->getName() + ",";
}
return strResult;
}
QString Queue::getCount() const
{
return QString::number(this->getCountInt());
}
int Queue::getCountInt() const
{
return this->queue.count();
}