r/programminghomework • • Nov 22 '18

Heaps Priority Queue

I have an assignment I am working on to make an emergency room simulator using heaps priority queues. So far I have it to where the priority works, but my professor wants it to where the name, complaint, priority, and ticket number appear in the end output. How would I go about changing my Add and Next methods to include the other items in the output? Thanks!

void Add(string name, string complaint, int priority)

{

	if (run == false)

	{

		//Build Mode

		Patient<T> patient(name, complaint, priority);

		

		heap.push_back(patient);

	}

	else if (run == true)

	{

		//Run Mode

		if (mode == MODE_MIN)
                {

bubble_up_min();

                }
                else
                {

bubble_up_max();

                }	
        }

}

/*T Peek()

{

}*/

T Next()

{

	//Copy the root into a temporary variable.

	T tmp = heap[1];

	//Move the back node to the front of the heap.

	T lastElement = heap[heap.size() - 1];

	heap[1] = lastElement;

	heap.pop_back();

	//Bubble Down the root.

	if (mode == MODE_MIN)

	{

		bubble_down_min(1);

	}

	else

		bubble_down_max(1);

	//std::cout << name << ", " << complaint << ", " << tmp << ", ";

	return tmp;

}

This is the error it gives me:

Error C2664 'void std::vector<T,std::allocator<_Ty>>::push_back(_Ty &&)': cannot convert argument 1 from 'Patient<T>' to 'const _Ty &'

1 Upvotes

0 comments sorted by