Skip to content

This is a simple implementation of a queue data structure in C. The queue is implemented using a linked list. The queue data structure is defined in queue.h and implemented in queue.c.

rafaelfigueredog/QueueInC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Queue

This is a simple implementation of a queue data structure in C. The queue is implemented using a linked list. The queue data structure is defined in queue.h and implemented in queue.c.

Usage

Initialization

To use the queue, include the queue.h header file in your code and create a new queue using the createQueue() function. This will return a pointer to the new queue.

#include "queue.h"
#include <stdio.h>

int main() {
  Queue *queue = createQueue();
  return 0;
}

Enqueue

To add an element to the queue, use the enqueue() function. This function takes a queue and an integer value as input and adds the value to the end of the queue.

enqueue(queue, 42);

Dequeue

To remove an element from the queue, use the dequeue() function. This function takes a queue as input and removes and returns the first element in the queue.

int value = dequeue(queue);

Front

To get the value of the first element in the queue without removing it, use the front() function. This function takes a queue as input and returns the value of the first element in the queue.

int value = front(queue);

Empty

To check if the queue is empty, use the isQueueEmpty() function. This function takes a queue as input and returns 1 if the queue is empty and 0 if it is not.

if (isQueueEmpty(queue)) {
  // Queue is empty
}

License

This code is released under the MIT License

About

This is a simple implementation of a queue data structure in C. The queue is implemented using a linked list. The queue data structure is defined in queue.h and implemented in queue.c.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages