-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqueue.h
More file actions
37 lines (27 loc) · 924 Bytes
/
Copy pathqueue.h
File metadata and controls
37 lines (27 loc) · 924 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
#ifndef QUEUE_H
#define QUEUE_H
typedef struct Queue
{
int front; //the array index of the front element
int rear; //the array index of the rear element
int size; //the number of elements in the queue
int capacity; //the capacity of the queue
int *array; //the pointer to the circular buffer
} Queue;
//create an empty queue with an array of the desired capacity
Queue *createQueue(int capacity);
//destroy the queue
Queue *destroyQueue(Queue *q);
//return 1 if the queue is empty, 0 otherwise
int isEmpty(Queue *q);
//make the queue empty
void makeEmpty(Queue *q);
//return 1 if the queue is full, 0 otherwise
int isFull(Queue *q);
//add a new element to the rear of the queue
void enqueue(Queue *q, int data);
//remove and return the front element from the queue
int dequeue(Queue *q);
//print the queue elements
void printQueue(Queue *q);
#endif