Using container/heap
In this subsection, you will see the functionality that the container/heap package offers. First of all, you should know that the container/heap package implements a heap, which is a tree where the value of each node of the tree is the smallest element in its subtree. Note that I am using the phrase smallest element instead of minimum value in order to make it clear that a heap does not only support numerical values.
However, as you can guess, in order to implement a heap tree in Go, you will have to develop a way to tell which of two elements is smaller than the other on your own. In such cases, Go uses interfaces because they allow you to define such a behavior.
This means that the container/heap package is more advanced ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access