Member Avatar for HASHMI007

Que.h Header file

template < class T>
class Que{

public :
	Que();
	Que(int max);
	~Que();
	int isFull()const ;
	int isEmpty()const ;
	void Insert( T newItem);
	void Remove(T & item);

private :

	int front , rear;
	int maxQue;
	int count ;
	T * Items;             // Dynamic Arry Implementation 


};
template < class T >
Que< T >::Que(){
	maxQue=100;
    front = 0; rear = 0 ; count =0;
	Items =new T [maxQue];              //Dynamic Memory Allocation 
}
template < class T >
Que< T >::Que(int max){

	maxQue=max;
	front =0;
	rear=0;
	count =0;
	Items= new T [maxQue];

}
template < class T >
Que< T >::~Que(){
	delete [] Items;
}
template < class T >
int Que< T >::isEmpty()const {

	return ( count == 0);
}
template < class T >
int Que< T >::isFull()const {

	return (count == maxQue);
}
template < class T >
void Que< T >::Insert( T newItem){

	if (isFull())
		cout<<"overFlow";
	else {

		Items[rear] = newItem;
		rear= (rear+ 1)%maxQue;
		++count ;
	}
}
template < class T >
void Que< T >::Remove(T & item){

	if(isEmpty())
		cout<<"UnderFlow";
	else
	{
	item= Items[rear];
	front = (front+1)%maxQue;
	--count;
	
	}
}

now i want to add a class which priority Queue ..Eny one plxx help me how i make proority que class

// Implemetation of PriorityQueue.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include"Que.h"
#include<iostream>
#include<conio.h>
#include<stdlib.h>


using namespace std;

template < class T >
class PriorityQue{

private :
	Que constr;
	T * ptr;
	int count front ,rear ;
public :
	
	int maxQue
	PriorityQue(int max):constr(int max){
	maxQue=m;
	}
	int IsEmpty();
	int IsFull();
	void PqInsert();
	void PqRemove();

};
template < class T >
priorityQue< T>::IsEpmty(){
	return (count ==0);
}

int main()
{
//Que<int>obj;
	 
getch();
return 0;
}

You need to make sure that it maintains a heap structure, that is the highest priority( or the lowest) is constantly at the top. So whenever a user inserts or deletes a node, you still need to maintain that property. There are several ways of doing this, check here for details.

Member Avatar for HASHMI007

I need more help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.