Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
queue/README.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
48 lines (34 sloc)
1.18 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A queue for you! | |
This is a dead simple queue implementation that only supports integers and | |
has the following interface: | |
```c | |
/* 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: | |
```c | |
$ make | |
$ ./queue_test | |
``` |