X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fsort.qh;h=cd0000912dfcfb65b715bcfabebf889d29144adc;hb=f6efc137bef946957459ddfcd447114bc2c9b7a5;hp=068707d0b649d9e709f6bd00711ba816da8eeea6;hpb=1a463f974e1c026a16a76dd042ebccb1085ad985;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/sort.qh b/qcsrc/lib/sort.qh index 068707d0b..cd0000912 100644 --- a/qcsrc/lib/sort.qh +++ b/qcsrc/lib/sort.qh @@ -5,21 +5,19 @@ USING(swapfunc_t, void (int i1, int i2, entity pass)); /** <0 for <, ==0 for ==, >0 for > (like strcmp) */ USING(comparefunc_t, int (int i1, int i2, entity pass)); -[[eraseable]] +ERASEABLE void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass) { #define heapify(_count) \ MACRO_BEGIN \ - { \ for (int start = floor(((_count) - 2) / 2); start >= 0; --start) \ { \ siftdown(start, (_count) - 1); \ } \ - } MACRO_END + MACRO_END #define siftdown(_start, _end) \ MACRO_BEGIN \ - { \ for (int root = (_start); root * 2 + 1 <= (_end); ) \ { \ int child = root * 2 + 1; \ @@ -28,7 +26,7 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass) swap(root, child, pass); \ root = child; \ } \ - } MACRO_END + MACRO_END heapify(n); int end = n - 1; @@ -40,7 +38,7 @@ void heapsort(int n, swapfunc_t swap, comparefunc_t cmp, entity pass) } } -[[eraseable]] +ERASEABLE void shuffle(float n, swapfunc_t swap, entity pass) { for (int i = 1; i < n; ++i)