50 lines
951 B
C
50 lines
951 B
C
|
#ifndef QUEUE_H
|
||
|
#define QUEUE_H
|
||
|
|
||
|
#include <stdbool.h>
|
||
|
|
||
|
/*
|
||
|
* Macro to create a new queue.
|
||
|
*/
|
||
|
#define queue(q) queue* q = newQueue();
|
||
|
|
||
|
typedef struct queue_element{
|
||
|
void* next;
|
||
|
void* element;
|
||
|
} queue_element;
|
||
|
|
||
|
typedef struct queue{
|
||
|
|
||
|
int size; /* The number of at in use */
|
||
|
queue_element* front; /* pointer to the first element of the queue */
|
||
|
queue_element* back; /* pointer to the back element of the queue */
|
||
|
|
||
|
void (*toString)(); /* Pointer to toString function */
|
||
|
} queue;
|
||
|
|
||
|
|
||
|
/*
|
||
|
* Creates new queue.
|
||
|
*/
|
||
|
queue* newQueue();
|
||
|
|
||
|
/*
|
||
|
* Adds a new element to the queue.
|
||
|
*/
|
||
|
void queuePush(queue* q, void* element);
|
||
|
|
||
|
void queuePrint(queue* q);
|
||
|
|
||
|
void queuePop(queue* q);
|
||
|
|
||
|
bool queueIsEmpty(queue* q);
|
||
|
|
||
|
void queueMerge(queue* q1, queue* q2);
|
||
|
|
||
|
void queueClear(queue* q);
|
||
|
|
||
|
void queueFree(queue* q);
|
||
|
|
||
|
void* queueTop(queue* q);
|
||
|
|
||
|
#endif
|