week 4 queue

This commit is contained in:
2021-03-23 09:48:23 +08:00
parent 942770dbc9
commit 01f2d61464
3 changed files with 177 additions and 0 deletions

37
week4/queue.h Normal file
View File

@@ -0,0 +1,37 @@
/*
* Authro: Walter
* Student ID: 1930006025
* Week4_queue
*/
#include <stdbool.h>
/* main queue structure */
typedef struct {
double *values;
int front; /* last one of queue */
int rear; /* the newest one in queue */
int counter;
int maxSize;
} Queue;
/* create an queue */
bool CreateQueue(Queue *queue, int size);
/* check whether the queue is empty*/
bool IsEmpty(Queue *queue);
/* check whether the queue is full */
bool IsFull(Queue *queue);
/* put value into queue */
bool Enqueue(Queue *queue, double x);
/* get value from queue */
bool Dequeue(Queue *queue, double *x);
/* display queue to stdout */
void DisplayQueue(Queue *queue);
/* destroy an queue */
void DestroyQueue(Queue *queue);