|
Our goal is to implement a priority queue using a heap. Here is a beginning, where a priority queue holds an array with its physical and logical sizes.
const int initHeapSize = 20; struct ItemAndPriority { int item; int prioirty; }; struct PriorityQueue { ItemAndPriority* A; // The heap int load; // The number of items in the heap int physicalSize; // The physical size of A. PriorityQueue() { load = 0; physicalSize = initHeapSize; A = new ItemAndPriority[initheapSize]; } };
|