Social Network 1.0.0
The second major course output (MCO2) for CCDSALG.
Loading...
Searching...
No Matches
queue.h File Reference

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.

Classes

struct  Queue
 A collection implementing the queue data structure using an array. More...

Typedefs

typedef struct Queue Queue
 A collection implementing the queue data structure using an array.

Functions

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.

Detailed Description

The helper functions that are used for handling and interacting with queues and their elements.

Author
Raphael Panaligan
Jek Degullado

Typedef Documentation

◆ 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.

Function Documentation

◆ dequeue()

void dequeue ( Queue *const queue)

Removes the element at the front of the queue.

Parameters
[in,out]queueThe 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]queueThe queue to add to.
[in]elementThe 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]queueThe queue to initialize.

◆ is_empty()

bool is_empty ( const Queue *const queue)

Checks if a queue contains contains no queueing elements.

Parameters
[in]queueThe 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]queueThe queue to check.
Returns
Whether the queue's rear index is MAX_STACK_LENGTH.

◆ peak()

void peak ( Queue *const queue,
Vertex element )

Gets the element at the front of the queue.

Parameters
[in]queueThe queue to get from.
[out]elementThe element at the front of the queue.
Precondition
The queue is not empty.