Since both std::priority_queue
and std::set
(and std::multiset
) are data containers that store elements and allow you to access them in an ordered fashion, and have same insertion complexity O(log n)
, what are the advantages of using one over the other (or, what kind of situations call for the one or the other?)?
While I know that the underlying structures are different, I am not as much interested in the difference in their implementation as I am in the comparison their performance and suitability for various uses.
Note: I know about the no-duplicates in a set. That's why I also mentioned std::multiset
since it has the exactly same behavior as the std::set
but can be used where the data stored is allowed to compare as equal elements. So please, don't comment on single/multiple keys issue.