Write the C priority int queue module pqueue (see https://en.wikipedia.org/wiki/Priority_ queue) as specified below. Your priorities will be integer values within the range specified where the larger the number the higher the priority. You must implement and export only the routines listed below (from file pqueue.h). Name your implementation file 'pqueue.c'.
Here is a listing of file pqueue.h
#ifndef PQUEUE_H
#define PQUEUE_H
#include < stdbool.h >
typedef struct pqueueType *pq;
// passing a NULL pq to any routine (except freepq) is undefined
pq createpq();
// creates a pqueue
void freepq(pq); // deallocates a pqueue; passing NULL ok. All memory
// management of the data should be left to the user
pq copy(pq q); // returns an exact (shallow) copy of p
/* priority p is defined as 0 <= p <= 100 where 0 is the lowest, 100 the highest */
void enq(pq q,void *item,int p); // inserts item with priority p into
// queue q; items added with the same
// priority are added after previous
// items with that priority
void deq(pq);
// removes item at front of q
void *front(pq); // returns item at front of q without removing it;
// is undefined if q is empty
int frontP(pq);
// returns priority of item at front without removing it;
// is undefined if q is empty
void *rear(pq);
// returns item at rear without removing it;
// is undefined if q is empty
int rearP(pq);
// returns priority of item at rear without removing it;
// is undefined if q is empty
int countP(pq q,int p); // returns count of items in q at priority p
int pqSize(pq); // current queue size
bool pqEmpty(pq);
bool pqFull(pq);
char *pqToString(pq,char *f(const void*)); // returns a string representation of queue;
// string must contain data item & priority
// in priority order highest to lowest
#endif
Along with the implementation file pqueue.c you need to turn in a minimum of two other files:
readme.txt A short text file briefly explaining the method (i.e. data structures) you used to implement your module along with a list of necessary files.
makeproj A single-line Unix script (text) file to build (compile) your code. This file will separately compile all of your C module files and create an object code library named projlib.a that I will then use to test your code. For example, if your module required files pqueue.c, mymod1.c, mymod2.c, and the C math library, your makeproj file would contain the following lines:
gcc -c pqueue.c mymod1.c mymod2.c -lm
ar -cvq projlib.a pqueue.o mymod1.o mymod2.o
Very important - if this file is incorrect or missing your project will not build!
You may implement the module in any way you choose with the following constraints: