From dddbe4b3203b7d15199010fcc2fcb8cfc8516e4c Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Mon, 30 Dec 2024 14:27:44 -0500 Subject: [PATCH] v4.0.4-rc --- include/data.h | 90 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 81 insertions(+), 9 deletions(-) diff --git a/include/data.h b/include/data.h index db87d87..55ff195 100644 --- a/include/data.h +++ b/include/data.h @@ -18,6 +18,8 @@ #ifndef GLACIERDATA_H_ #define GLACIERDATA_H_ +#include + /* * create_node * @@ -58,7 +60,7 @@ void add_child(struct node *parent, struct node *child); /* * print_tree * - * DESCRIPTION: Print_tree prints a dependency tree specified at its root node + * DESCRIPTION: Print_tree prints a dependency tree specified at its root node. * PARAMETERS: * struct node *root -> The tree to print * int level -> The number of levels to descend @@ -74,6 +76,16 @@ void print_tree(struct node *root, int level); /**************************************************************************************************************/ +/* + * queue + * + * DESCRIPTION: Queue is a type definition for the queue data structure. + */ + +typedef struct queue; + +/**************************************************************************************************************/ + /* * init_queue * @@ -95,7 +107,7 @@ void init_queue(queue *q); /* * queue_is_empty * - * DESCRIPTION: Queue_is_empty checks if queue *q is empty + * DESCRIPTION: Queue_is_empty checks if queue *q is empty. * PARAMETERS: * queue *q -> The queue to check * RETURN VALUES: @@ -116,7 +128,7 @@ bool queue_is_empty(queue *q); /* * queue_is_full * - * DESCRIPTION: Queue_is_full checks if queue *q is full + * DESCRIPTION: Queue_is_full checks if queue *q is full. * PARAMETERS: * queue *q -> The queue to check * RETURN VALUES: @@ -137,20 +149,80 @@ bool queue_is_full(queue *q); /* * enqueue * - * DESCRIPTION: Enqueue enqueues an element at the back of the queue + * DESCRIPTION: Enqueue enqueues an element at the back of the queue. * PARAMETERS: * queue *q -> The queue to enqueue to - * int value -> + * int value -> The value of the element to enqueue * RETURN VALUES: - * true on full, false on not full + * None. * CAVEATS: * None. * EXAMPLE: - * if (queue_is_full(q)) { - * printf("Queue is full\n"); - * return; + * if (! queue_is_full(q)) { + * enqueue(q, 15); * } */ +void enqueue(queue *q, int value); + +/**************************************************************************************************************/ + +/* + * dequeue + * + * DESCRIPTION: Dequeue dequeues an element at the front of the queue. + * PARAMETERS: + * queue *q -> The queue to dequeue to + * RETURN VALUES: + * None. + * CAVEATS: + * None. + * EXAMPLE: + * if (! queue_is_empty(q)) { + * dequeue(q); + * } + */ + +void dequeue(queue *q); + +/**************************************************************************************************************/ + +/* + * peek + * + * DESCRIPTION: Peek displays the first element in a specified queue. + * PARAMETERS: + * queue *q -> The queue to peek at + * RETURN VALUES: + * -1 on queue is empty, element value (!= -1) on success + * CAVEATS: + * None. + * EXAMPLE: + * if (! queue_is_full(q)) { + * peek(q); + * } + */ + +int peek(queue *q); + +/**************************************************************************************************************/ + +/* + * print_queue + * + * DESCRIPTION: Print_queue displays the contents of the queue in order. + * PARAMETERS: + * queue *q -> The queue to print + * RETURN VALUES: + * None. + * CAVEATS: + * None. + * EXAMPLE: + * if (! queue_is_full(q)) { + * print_queue(q); + * } + */ + +void print_queue(queue *q); #endif