#include <iostream.h>
#include <stdlib.h>
const int MaxPQSize=50;
class PQueue
{
private:
int count;
DataType ;pqlist[MaxPQSize];
public:
PQueue(void);
void PQInsert(const DataType,item);
DataType PQDelete(void);
void ClearPQ(void);
int PQEmpty(void) const;
int PQFull(void) const;
int PQLength(void) const;
virtual ~PQueue();
};
void PQueue::PQInsert(const DataType& item)
{
if(count==MaxPQSize)
{
cerr<<"Priority queue overflow!"<<endl;
exit(1);
}
pqlist[count]=item;
count++;
}
DataType PQueue::PQDelete(void)
{
DataType min;
int i,minandex=0;
if(count>0)
{
min=pqlist[0];
for(i=1;i<count;i++)
if(pqlist[i]<min)
{
min=pqlist[i];
minindex=i;
}
pqlist[minindex]=pqlist[count-1];
count--;
}
else
{
cerr<<"Deleting from an empty pqueue!"<<endl;
exit(1);
}
return min;
}