A queue for you!
This is a dead simple queue implementation that only supports integers and has the following interface:
/* Create a brand new queue out of thin air. */
Queue* create_queue();
/* Take a peek at what's at the front of the queue. */
int front(Queue* queue);
/* Take a peek at what's at the back of the queue. */
int back(Queue* queue);
/* Enqueue an integer to the front of the queue. */
void enqueue(Queue* queue, int data);
/* Dequeue an integer from the queue. */
int dequeue(Queue* queue);
/* Send the queue into non-existance. */
void destroy_queue(Queue* queue);
/* Print out all of the elements of the queue. */
void print_queue(Queue* queue);
/* Determine how many elements are in the queue. */
size_t size(Queue* queue);
/* Determine if the queue is empty like my soul. */
int is_empty(Queue* queue);
How to use
To use this wonderful queue, just include "queue.h"
and you're good to go!
Testing
If you'd like to verify this queue implementation actually works, you can run
the unit tests! All the unit tests are located in queue_test.c
and make use
of my amazing simple_unit_test
testing framework.
To run the unit tests:
$ make
$ ./queue_test