You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
762 B
C
48 lines
762 B
C
#include "queue.h"
|
|
|
|
QUEUE(int, 4);
|
|
|
|
queue_int_t queue;
|
|
|
|
void display(queue_int_t* queue)
|
|
{
|
|
if (queue->csize == 0)
|
|
{
|
|
printf("queue is empty\n");
|
|
}
|
|
else
|
|
{
|
|
printf("Queue:\n");
|
|
int i = queue->head;
|
|
for (int j = 0; j < queue->csize; j++)
|
|
{
|
|
printf("[%d]: %d ", i + j, queue->data[(i + j) % queue->msize]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
|
|
int main(int argv, char** argc)
|
|
{
|
|
queue_int_init(&queue);
|
|
|
|
// queue.enqueue(&queue, 10);
|
|
queue.empty(&queue);
|
|
printf("csize: %d\n", queue.csize);
|
|
queue.enqueue(&queue, 20);
|
|
queue.enqueue(&queue, 30);
|
|
queue.enqueue(&queue, 40);
|
|
display(&queue);
|
|
queue.enqueue(&queue, 10);
|
|
|
|
int val = 0;
|
|
queue.dequeue(&queue, &val);
|
|
queue.dequeue(&queue, &val);
|
|
|
|
display(&queue);
|
|
|
|
queue.empty(&queue);
|
|
|
|
display(&queue);
|
|
}
|