I need a priority_queue for my structs. I want to construct one using both initial data from an array and a custom comparator:
class mycomparison
{
public:
mycomparison(const bool& maxOnTop=false, const int& compField = 0);
...
};
mergeRecord initialRecords[N]; // my array
mycomparison(false, field); // my custom comparator
std::priority_queue<mergeRecord, std::vector<mergeRecord>, mycomparison>
recsHeap(???);
On the cplusplus reference, there is an example of how to initialize a priority_queue object with a comparator OR an array with initial values. How would I do both? I know I could insert them one by one, but this would cost O(nlogn) whereas passing them all at once is O(n).