[urgent]Priority Queue

I implement copy constructor for priority queue like this, is it right?

1
2
3
4
5
6
7
8
9
10
PRIORITY_QUEUE<T>::PRIORITY_QUEUE(const PRIORITY_QUEUE &aQueue)
{
	this->maxSize = aQueue.maxSize;
	this->items = new T [maxSize + 1];
	this->rear = aQueue.rear;
	for (int i = 0; i < aQueue.rear; i++)
	{
		this->items[i] = aQueue.items[i];
	}
}


here is the class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class PRIORITY_QUEUE 
{
private:
	T *items; // array of queue items
	int rear;
	int maxSize; // maximum size of queue
	void heapify(int i); // adjust heap at position ā€œiā€
public:
	.......							
	PRIORITY_QUEUE(const PRIORITY_QUEUE &aQueue);
	......
	......
	void insert(T newItem);
	T deleteMin();
	T minValue();
};


By the way, how to implement "insert" and "heapify"
and in insert, when we insert an element we also heapify it?
Why maxSize+1?

Otherwise ok, sort of .

i don't know what heapif y means.
thnks, anyone help "insert" and "heapify"
Topic archived. No new replies allowed.