Queue
This is a simple stack-like queue system for queuing general data.
Creating a new queue
Creating a queue is fairly simple as it just requires one function with no arguments.
Queue* queue = new_queue();
Pushing to the queue
Pushing specific data to queue is also fairly simple.
queue_push(queue, (void*) "Hello world");
Retrieving the current item from the queue
To get our current item from the queue it will just do queue->current
but it also checks if the queue itself exists, if not it will return NULL.
void* current = current_queue(queue)
Jumping to the next element
Jumping to the next element involves using the queue_pop
function to pop the current item and setting it the next item. This can be done by just simple calling the function
queue_pop(queue)
Freeing the queue
Now since the queue is manually allocated you will also need to manually free it. This can be done by using the queue_free
method which frees every queue in the given queue.
queue_free(queue)
Last updated