Attempted to separate the snippets of code to small functions and each set of functions have its own file. Also made some improvements by using pools instead of constantly mallocing space.
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
#ifndef QUEUE_H
|
||||
#define QUEUE_H
|
||||
|
||||
#include "utils.h"
|
||||
#include "node.h"
|
||||
|
||||
/**
|
||||
* @brief Initializes the queue with a maximum number of elements
|
||||
* @param max_elements The maximum number of elements the queue can hold
|
||||
*/
|
||||
void q_init(int max_elements);
|
||||
|
||||
/**
|
||||
* @brief Pushes a node into the queue
|
||||
* @param n The node to push into the queue
|
||||
*/
|
||||
void q_push(Node* n);
|
||||
|
||||
/**
|
||||
* @brief Returns the node from the front of the queue
|
||||
* @return The node from the front of the queue
|
||||
*/
|
||||
Node* q_pop();
|
||||
|
||||
/**
|
||||
* @brief Returns the current size of the queue
|
||||
* @return The current size of the queue
|
||||
*/
|
||||
int q_size();
|
||||
|
||||
/**
|
||||
* @brief Clears the queue without freeing memory
|
||||
*/
|
||||
void q_clear();
|
||||
|
||||
/**
|
||||
* @brief Reset the queue memory
|
||||
*/
|
||||
void q_destroy();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user