// Implementation of a Queue
// that stores integers
// Follows First-in-First-out rules
// and is implemented using a linked list
// Marc Chee (cs1511@cse.unsw.edu.au), July 2020
#include "queue.h"
#include <stdlib.h>
struct queueInternals {
struct queueNode *head;
struct queueNode *tail;
};
struct queueNode {
int data;
struct queueNode *next;
};
static struct queueNode *createNode(int data);
// Create the queueInternals and make it ready for use
Queue queueCreate() {
Queue newQueue = malloc(sizeof(struct queueInternals));
newQueue->head = NULL;
newQueue->tail = NULL;
return newQueue;
}
// Add an item to the queue.
// In the linked list, this adds to the end of the list
void queueAdd(Queue q, int item) {
// create the new item
// tail's next aims at the new item
// move the tail to the newly added item
}
////////////// HELPER FUNCTIONS ///////////////////////
// Create a single node using data
static struct queueNode *createNode(int data) {
}
Resource created Tuesday 28 July 2020, 11:26:22 AM.
file: queue.c