Reputation: 3177
std::priority_queue< int, std::vector<int>, std::greater<int> > pq;
Why is the vector parameter used?
Upvotes: 0
Views: 119
Reputation: 7482
The priority queue implementation can use different types of containers to build the underlining data structure. You can specify which one you like the most using that template parameter.
Quoting from here
Container - The type of the underlying container to use to store the elements. The container must satisfy the requirements of SequenceContainer, and its iterators must satisfy the requirements of RandomAccessIterator. Additionally, it must provide the following functions with the usual semantics: front() push_back() pop_back() The standard containers std::vector and std::deque satisfy these requirements.
Btw, vector
is the default one.
Upvotes: 2