The helper functions that are used for handling and interacting with queues and their elements.
More...
#include <stddef.h>
#include "graph.h"
Go to the source code of this file.
|
void | initialize_queue (Queue *const queue) |
| Initializes a queue’s data and indexes to their default values.
|
void | enqueue (Queue *const queue, const Vertex element) |
| Adds an element to the rear of the queue.
|
void | dequeue (Queue *const queue) |
| Removes the element at the front of the queue.
|
void | peak (Queue *const queue, Vertex element) |
| Gets the element at the front of the queue.
|
bool | is_full (const Queue *const queue) |
| Checks if a queue contains the maximum number of elements.
|
bool | is_empty (const Queue *const queue) |
| Checks if a queue contains contains no queueing elements.
|
The helper functions that are used for handling and interacting with queues and their elements.
- Author
- Raphael Panaligan
-
Jek Degullado
- Copyright
- GNU AGPLv3
◆ Queue
typedef struct Queue Queue |
A collection implementing the queue data structure using an array.
This is a simple implementation, not a circular implementation. Therefore, the queue can only be consumed once.
◆ dequeue()
void dequeue |
( |
Queue *const | queue | ) |
|
Removes the element at the front of the queue.
- Parameters
-
[in,out] | queue | The queue to remove from. |
- Precondition
- The queue is not empty.
◆ enqueue()
void enqueue |
( |
Queue *const | queue, |
|
|
const Vertex | element ) |
Adds an element to the rear of the queue.
- Parameters
-
[in,out] | queue | The queue to add to. |
[in] | element | The element to add. |
- Precondition
- The queue is not full.
◆ initialize_queue()
void initialize_queue |
( |
Queue *const | queue | ) |
|
Initializes a queue’s data and indexes to their default values.
- Parameters
-
[in,out] | queue | The queue to initialize. |
◆ is_empty()
bool is_empty |
( |
const Queue *const | queue | ) |
|
Checks if a queue contains contains no queueing elements.
- Parameters
-
[in] | queue | The queue to check. |
- Returns
- Whether the queue’s front and rear indexes are equal.
◆ is_full()
bool is_full |
( |
const Queue *const | queue | ) |
|
Checks if a queue contains the maximum number of elements.
- Parameters
-
[in] | queue | The queue to check. |
- Returns
- Whether the queue's rear index is MAX_STACK_LENGTH.
◆ peak()
Gets the element at the front of the queue.
- Parameters
-
[in] | queue | The queue to get from. |
[out] | element | The element at the front of the queue. |
- Precondition
- The queue is not empty.