forked from jwasham/practice-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue_array.h
More file actions
35 lines (28 loc) · 785 Bytes
/
queue_array.h
File metadata and controls
35 lines (28 loc) · 785 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
#include <iostream>
#ifndef PROJECT_QUEUE_ARRAY_H
#define PROJECT_QUEUE_ARRAY_H
namespace jw {
template <class T>
class Queue {
static const int kQueueCapacity = 5;
static const int kQueuePositions = kQueueCapacity + 1;
public:
explicit Queue() : insert_(0), pop_(0) {}
~Queue() = default;
Queue(const Queue &) = delete;
Queue &operator=(const Queue &) = delete;
// Adds value to queue.
void Enqueue(T value);
// Removes least recently added item from queue, returning its value.
const T Dequeue();
// Returns true if queue is empty.
bool Empty() const;
// Returns true if queue cannot accept another enqueue.
bool Full() const;
private:
int insert_;
int pop_;
T data_[kQueuePositions];
};
} // namespace jw
#endif // PROJECT_QUEUE_ARRAY_H