c++ - merge two priority queues -


this question has answer here:

std::priority_queue<some_type, std::vector<some_type>, some_comparator> a; std::priority_queue<some_type, std::vector<some_type>, some_comparator> b; 

how can merge these priority queues , b based on same comparator. tried find builtin function not find any.

the simplest way move objects 1 queue another:

while(!b.empty()) {     a.push(b.top());     b.pop(); } 

there might exist more efficient method, though.


Comments