MCPcopy Create free account
hub / github.com/anupam-kumar-krishnan/Competitive_Programming / createQueue

Function createQueue

Basic Programming/queue.c:16–28  ·  view source on GitHub ↗

function to create a queue of given capacity. It initializes size of queue as 0

Source from the content-addressed store, hash-verified

14// of given capacity.
15// It initializes size of queue as 0
16struct Queue* createQueue(unsigned capacity)
17{
18 struct Queue* queue = (struct Queue*)malloc(
19 sizeof(struct Queue));
20 queue->capacity = capacity;
21 queue->front = queue->size = 0;
22
23 // This is important, see the enqueue
24 queue->rear = capacity - 1;
25 queue->array = (int*)malloc(
26 queue->capacity * sizeof(int));
27 return queue;
28}
29
30// Queue is full when size becomes
31// equal to the capacity

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected