<p dir="ltr">These are standard heap algorithms whose operation should be easily recognisable.  The build loop runs over the set of non-leaf nodes, implicitly accessing both children which are automatically at double the index.</p>
<p dir="ltr">The timeout is simply there to elide the overhead of maintaining the heap when hard dropping hasn't been necessary for a while.</p>
<p dir="ltr"> - Jonathan Morton<br>
</p>