I’m using priority_queue with a vector as an underlying container. However I expect the size of the heap to be very large. I’m aware of problems with dynamic vector capacity resize. So I’m looking for ways to initially allocate enough space for the underlying vector in my priority_queue. Are there any suggestions out there to achieve this?
Thanks
stdlib container adaptors provide a “back door” to access the underlying container: the container is a protected member called
c.Therefore you can inherit from the adapter to gain access to the container:
If you feel bad about inheriting from a stdlib class, use private inheritance and make all the methods of
priority_queueaccessible withusingdeclarations.