I have created a d-ary heap in Zig, mostly as a learning exercise.
To my surprise, this heap is almost twice as fast as the std.PriorityQueue
binary heap for a benchmark where n elements are inserted into the heap and are all removed.
I think the major improvement in performance is coming from separating the (more common usually) case where you do not need to check for slice bounds when finding children in the “sift-down” function.