I am currently assigned a project to simulate a carwash in C++ using a priority queue and a heap. Basic synopsis:
1. a car enters the carwash.
2. if there are no parking spaces the car departs (must keep track of number of
cars that depart without getting a wash).
3. if there is parking the car parks and waits for the next available wash bay.
4. The service (wash, wax, and or vacuum) is performed and the vehicle departs and
the process continues.

The simulation must keep track of all of the above actions for a final report containing
number of customers who successfully complete each type of task as well as the number of
customers who depart without doing anything.

I've got the queue for parking spaces operating but am having problems even getting started with the priority queue and the heap usage. Any assistance would be appreciated.

6 Years
Discussion Span
Last Post by Dink3465

Thanks for your assistance David. I have spent more time in the past couple of days learning more about priority queues than I wanted to know. I believe I have an approach now.

A priority queue acts just like a queue but rather than maintain the order that the items were added to the queue, the priority queue sorts the items as they are added. Here is an example:

As I understand, a heap is the same as a priority queue.

Good luck,


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.