Hi yall!
I have to create a priority queue with out using built in librarys. I have tried to write a bit of code so far, however I dont know if it works and am a little confused on a few things.
What follows this line is the main cpp file of the project.....
#include <cstdio>
#include "stdafx.h"
#include "pqueue.h"
using namespace std;
//Structure PQCell holds an item (item), priority (priority) and
//a pointer to the next item in the priority queue.
struct PQCell
{
ItemType item;
PriorityType priority;
PQCell* node;
PQCell() : item(0), priority(0), node()
{
}
};
//Checks the the first element of the linked list (q) for
//a NULL value. If the list is empty this first element will be NULL.
bool isEmpty(const PriorityQueue& q)
{
if (q.next == NULL)
{
return false;
}
return true;
}
//-------------------------------------------------------------------
void insertCell(PriorityQueue& L, ItemType x, PriorityType p)
{
PQCell cell;
cell.item = x;
cell.priority = p;
}
void insert(PriorityQueue& q, ItemType x, PriorityType p)
{
insertCell(q, x, p);
}
int main()
{
return 0;
}
What follows this line is the header file that is supposed to accompany the main cpp file...
// CSCI 2530
// Assignment: ***
// Author: ***
// File: ***
// Tab stops: ***
// **Say what this program does here. (replace this comment)**
#include <cstdio>
using namespace std;
struct PQCell;
//Type definitions
typedef const char* ItemType;
typedef double PriorityType;
typedef void(*ItemPrinter)(ItemType);
typedef void(*PriorityPrinter)(PriorityType);
struct PriorityQueue
{
PriorityQueue* next;
PriorityQueue()
{
next = NULL;
}
};
//Prototypes
bool isEmpty(const PriorityQueue& q);
void insert(PriorityQueue& q, ItemType x, PriorityType p);
I really am having a hard time understanding linked lists and how the pointers work in this project
Any help would be appriciated!
Also, here is the link to my assignment instructions...... http://cs.ecu.edu/~karl/2530/spr18/Assn/Assn6/assn6.html