How can I preallocate a std::priority_queue
with a container of type std::vector
?
std::priority_queue<unsigned char, std::vector<unsigned char>> pq;
pq.c.reserve(1024);
Does not compile because the underlying vector is a protected member.
Is it possible to use the constructor of the priority_queue
to wrap it around a pre-reserved vector?
vector<pair<int, int>> container2; container2.reserve(1024); priority_queue<pair<int, int>, vector<pair<int, int>>> minheap (greater<pair<int, int>>(), move(container2));
? – Stimulate