-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQueue.h
More file actions
40 lines (32 loc) · 905 Bytes
/
Copy pathQueue.h
File metadata and controls
40 lines (32 loc) · 905 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
#ifndef QUEUE_H
#define QUEUE_H
#include "Node.h"
class QueueArray {
private:
int* arr;
int capacity;
int frontIndex;
int rearIndex;
int count;
public:
explicit QueueArray(int capacity);
~QueueArray();
void enqueue(int value);
int dequeue();
bool isFull() const;
bool isEmpty() const;
void display() const;
};
class QueueLinkedList {
private:
Node* front; //points to first element to be dequeued
Node* rear; //points to last element in the queue
public:
QueueLinkedList();
~QueueLinkedList();
void enqueue(int value); // Add an element to the rear of the queue
int dequeue(); // Remove and return the element at the front of the queue. If the queue is empty, return -1 .
bool isEmpty() const; // Check if the queue is empty
void display() const; //print all elements in the queue from front to rear.
#endif
};