11 #define heapify(_count) MACRO_BEGIN \
12 for (int start = floor(((_count) - 2) / 2); start >= 0; --start) \
13 siftdown(start, (_count) - 1); \
16 #define siftdown(_start, _end) MACRO_BEGIN \
17 for (int root = (_start); root * 2 + 1 <= (_end); ) \
19 int child = root * 2 + 1; \
20 if (child < (_end) && cmp(child, child + 1, pass) < 0) \
22 if (cmp(root, child, pass) >= 0) \
24 swap(root, child, pass); \
42 for (
int i = 1; i < n; ++i)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define pass(name, colormin, colormax)
#define siftdown(_start, _end)
ERASEABLE void shuffle(float n, swapfunc_t swap, entity pass)
ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass)
int(int i1, int i2, entity pass) comparefunc_t
<0 for <, ==0 for ==, >0 for > (like strcmp)
void(int i1, int i2, entity pass) swapfunc_t
is only ever called for i1 < i2