by florianist · 4y ago · 0 comments
A priority queue is usually implemented as a heap (binary or otherwise) and frequently called that as well, but in more precise usage the gadget (abstract data type) you do INSERT and REMOVE-MIN to is the “priority queue”, and the implementation device of a(n implicit or explicit) tree where the value in any node is smaller than the values in its children is the “heap”. Roughly, “priority queue” is to “heap” like “ordered dictionary / map” is to “search tree”.
(I can’t think of any data structures that use heaps not for a priority queue except for treaps, but then my algorithm-fu is not particularly strong.)
As for shared_ptr, it’s just a refcounted pointer, but that bit of terminology is STL-specific so there might not be much value in learning it.
(e.g. I would just call it "refcnt_ptr" and "heap" [if it is one], respectively)
The STL was designed by A. Stepanov, who I suspect is simply too intelligent for this world. I have no idea what he's talking about half the time, but the rest is brilliant. Long story short; it's trying to solve a much bigger problem using a tool that wasn't built for it.