-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindigoqueue.cpp
99 lines (80 loc) · 1.56 KB
/
indigoqueue.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include "indigoqueue.h"
#include <QtCore>
IndigoQueue::~IndigoQueue(void)
{
}
void IndigoQueue::push(char data)
{
queue.enqueue(data);
}
void IndigoQueue::pushAll(QByteArray &array)
{
foreach (char a, array)
{
push(a);
}
}
char IndigoQueue::pop()
{
if(queue.size() <= 0)
{
// You should handle Queue underflow the way you want here.
qDebug() << "queue underflow!!!";
return -1;
}
return queue.dequeue();
}
char IndigoQueue::peek()
{
if(queue.size() <= 0)
{
// You should handle Queue underflow the way you want here.
qDebug() << "queue underflow!!!";
return -1; // сообщение ни о чём
}
return queue.head();
}
bool IndigoQueue::isEmpty()
{
return queue.size() == 0;
}
int IndigoQueue::size()
{
return queue.size();
}
// ----------------------
IndigoOrderQueue::~IndigoOrderQueue(void)
{
}
void IndigoOrderQueue::push(hello data)
{
queue.enqueue(data);
}
hello IndigoOrderQueue::pop()
{
if(queue.size() <= 0)
{
// You should handle Queue underflow the way you want here.
qDebug() << "queue underflow!!!";
return hello::default_instance();
}
return queue.dequeue();
}
hello IndigoOrderQueue::peek()
{
if(queue.size() <= 0)
{
// You should handle Queue underflow the way you want here.
qDebug() << "queue underflow!!!";
return hello::default_instance(); // сообщение ни о чём
}
return queue.head();
}
bool IndigoOrderQueue::isEmpty()
{
return queue.size() == 0;
}
int IndigoOrderQueue::size()
{
return queue.size();
}