Git Product home page Git Product logo

queuec's Introduction

Queue C

This is a simple queue implementation in C using an array. The queue is implemented as a normal queue.

Functions

  • Queue* createQueue(int size): Create a queue with a given size.
  • void destroyQueue(Queue* queue): Destroy the queue object.
  • bool isEmpty(Queue* queue): Check if the queue is empty
  • bool isFull(Queue* queue): Check if the queue is full
  • void enqueue(Queue* queue, int element): Enqueue an element to the queue
  • int dequeue(Queue* queue): Dequeue an element from the queue
  • int getFront(Queue* queue): Get the front element of the queue.
  • int getRear(Queue* queue): Get the rear element of the queue.
  • int getSize(Queue* queue): Get the size of the queue

Usage

// Create a queue
Queue* queue = createQueue(5);

// Enqueue elements
enqueue(queue, 1);
enqueue(queue, 2);
enqueue(queue, 3);
enqueue(queue, 4);
enqueue(queue, 5);

// Check if the queue is full
if (isFull(queue)) {
    printf("Queue is full!\n");
} else {
    printf("Queue is not full!\n");
}

// Dequeue elements
printf("Dequeue: %d\n", dequeue(queue));
printf("Dequeue: %d\n", dequeue(queue));
printf("Dequeue: %d\n", dequeue(queue));

// Get the front element
printf("Front: %d\n", getFront(queue));

// Get the rear element
printf("Rear: %d\n", getRear(queue));

// Get the size of the queue
printf("Size: %d\n", getSize(queue));

// Destroy the queue
destroyQueue(queue);

License

This project is licensed under the GPL-3.0 License - see the LICENSE file for details.

© Copyright Max Base, 2022

queuec's People

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.