3 ms·
I did a slightly different generic implementation of heaps here: https://github.com/addrummond/heap https://github.com/addrummond/heap The main difference is t
by foldr 3y ago
I did a slightly different generic implementation of heaps here: https://github.com/addrummond/heap https://github.com/addrummond/heap
The main difference is that is that the comparison function is determined from the type of the heap element both for built-in and user-defined types.
- kiitos 3y agoconst ( Break BreakOrContinue = iota Continue BreakOrContinue = iota ) This is not how `iota` works...
- lifthrasiir 3y agoAmazingly enough, it is (try it yourself!). This predefined identifier changes its value for every constant declaration [1], and the declaration itself just fills the expression list from the previous when missing. [1] https://go.dev/ref/spec#Iota https://go.dev/ref/spec#Iota
- deleted 3y ago[deleted]
- foldr 3y agoHmm, as the sister comment points out, this sets Break and Continue to different values, which is all that’s required. Maybe there is a more stylish way of accomplishing the same thing that I’m unaware of, but it’s not a bug. This is a nice example of the bizarre negativity you tend to get when posting any project on an Internet forum. I don’t expect anyone to be even remotely impressed by my implementation of a completely standard binary heap. But it’s amusing that the one comment that this has attracted is a piece of snark that appears not even to be technically correct.