Skip to content

Latest commit

 

History

History

dynamic-queue

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Dynamic Queue

queue.c

struct data {
  unsigned int key;
  int value;
};

struct node {
  struct data *data;
  struct node *next;
};

struct queue {
  struct node *front;
  int unsigned size;
  int unsigned length;
};

queue.h

Creates a queue.

Queue* create(int unsigned size);

Adds an element to the rear of the queue.

void enqueue(Queue *queue, unsigned int key, int value);

Removes the element from the front of the queue.

void dequeue(Queue *queue);

Print queue nodes.

void print(Queue *queue);

Prints the data of a node.

void printNode(Node *node);

Returns the element at the front of the queue without removing it.

Node* peek(Queue *queue);

Checks if the queue is empty.

bool isEmpty(Queue *queue);

Checks if the queue is full.

bool isFull(Queue *queue);

Calculates the queue length.

unsigned int length(Queue *queue);