The OpenD Programming Language

HeapOps.percolate

Alternate version of siftDown that performs fewer comparisons, see https://en.wikipedia.org/wiki/Heapsort#Bottom-up_heapsort. The percolate process first sifts the parent all the way down (without comparing it against the leaves), and then a bit up until the heap property is restored. So there are more swaps but fewer comparisons. Gains are made when the final position is likely to end toward the bottom of the heap, so not a lot of sifts back are performed. template because of @@@12410@@@

template HeapOps(alias less, Range)
void
percolate
()
(
Range r
,
size_t parent
,
immutable size_t end
)

Meta