I can't seem to make a performant D-ary Heap class in C#; a hard-coded number of children (BinaryHeap, TernaryHeap, etc.) seems to have significantly better performance.
The only difference in the code between my BinaryHeap and my D-ary Heap with d=2, is that d is a const in the prior, and a readonly member variable in the latter (and readonly has no affect on performance).
I'm guessing the const version might compile down to a bit-shifting operation whereas the member variable version might compile down to memory-fetch + devision.
Is there a way I could declare my class sorta like this:
 public class DaryHeap<T, const uint(d)> : IEnumerable<T> where T : IComparable<T>
Wherein const uint(d) would tell the compiler "d is a compile-time uint value". And thus, would let my D-ary Heap with d=2 perform identically to my BinaryHeap.
 
     
     
    