public static int lower <T>(global::Array <T> a, global::haxe.lang.Function cmp, int @from, int to, int val) { unchecked { #line 140 "/opt/haxe/std/haxe/ds/ArraySort.hx" int len = (to - @from); #line 140 "/opt/haxe/std/haxe/ds/ArraySort.hx" int half = default(int); #line 140 "/opt/haxe/std/haxe/ds/ArraySort.hx" int mid = default(int); while ((len > 0)) { #line 142 "/opt/haxe/std/haxe/ds/ArraySort.hx" half = (len >> 1); mid = (@from + half); #line 144 "/opt/haxe/std/haxe/ds/ArraySort.hx" if ((((int)(cmp.__hx_invoke2_f(default(double), a[mid], default(double), a[val]))) < 0)) { #line 145 "/opt/haxe/std/haxe/ds/ArraySort.hx" @from = (mid + 1); len = ((len - half) - 1); } else { #line 148 "/opt/haxe/std/haxe/ds/ArraySort.hx" len = half; } } #line 150 "/opt/haxe/std/haxe/ds/ArraySort.hx" return(@from); } #line default }
public static void rec <T>(global::Array <T> a, global::haxe.lang.Function cmp, int @from, int to) { unchecked { #line 47 "/opt/haxe/std/haxe/ds/ArraySort.hx" int middle = ((@from + to) >> 1); if (((to - @from) < 12)) { #line 49 "/opt/haxe/std/haxe/ds/ArraySort.hx" if ((to <= @from)) { #line 50 "/opt/haxe/std/haxe/ds/ArraySort.hx" return; } #line 51 "/opt/haxe/std/haxe/ds/ArraySort.hx" { #line 51 "/opt/haxe/std/haxe/ds/ArraySort.hx" int _g = (@from + 1); #line 51 "/opt/haxe/std/haxe/ds/ArraySort.hx" int _g1 = to; #line 51 "/opt/haxe/std/haxe/ds/ArraySort.hx" while ((_g < _g1)) { #line 51 "/opt/haxe/std/haxe/ds/ArraySort.hx" int i = _g++; int j = i; #line 53 "/opt/haxe/std/haxe/ds/ArraySort.hx" while ((j > @from)) { #line 54 "/opt/haxe/std/haxe/ds/ArraySort.hx" if ((((int)(cmp.__hx_invoke2_f(default(double), a[j], default(double), a[(j - 1)]))) < 0)) { #line 55 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.swap <T>(((global::Array <T>)(a)), ((int)((j - 1))), ((int)(j))); } else { #line 57 "/opt/haxe/std/haxe/ds/ArraySort.hx" break; } #line 58 "/opt/haxe/std/haxe/ds/ArraySort.hx" --j; } } } #line 61 "/opt/haxe/std/haxe/ds/ArraySort.hx" return; } #line 63 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.rec <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(@from)), ((int)(middle))); global::haxe.ds.ArraySort.rec <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(middle)), ((int)(to))); #line 65 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.doMerge <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(@from)), ((int)(middle)), ((int)(to)), ((int)((middle - @from))), ((int)((to - middle)))); } #line default }
public void quicksort(int lo, int hi, global::haxe.lang.Function f) { unchecked { T[] buf = this.__a; int i = lo; int j = hi; T p = buf[((i + j) >> 1)]; while ((i <= j)) { while ((((int)(f.__hx_invoke2_f(default(double), default(double), buf[i], p))) < 0)) { i++; } while ((((int)(f.__hx_invoke2_f(default(double), default(double), buf[j], p))) > 0)) { j--; } if ((i <= j)) { T t = buf[i]; buf[i++] = buf[j]; buf[j--] = t; } } if ((lo < j)) { this.quicksort(lo, j, f); } if ((i < hi)) { this.quicksort(i, hi, f); } } }
public void quicksort(int lo, int hi, global::haxe.lang.Function f) { unchecked { T[] buf = this.__a; int i = lo; int j = hi; T p = global::haxe.lang.Runtime.genericCast <T>(buf[((i + j) >> 1)]); while ((i <= j)) { while (((i < hi) && (((int)(f.__hx_invoke2_f(default(double), global::haxe.lang.Runtime.genericCast <T>(buf[i]), default(double), p))) < 0))) { ++i; } while (((j > lo) && (((int)(f.__hx_invoke2_f(default(double), global::haxe.lang.Runtime.genericCast <T>(buf[j]), default(double), p))) > 0))) { --j; } if ((i <= j)) { T t = global::haxe.lang.Runtime.genericCast <T>(buf[i]); buf[i++] = global::haxe.lang.Runtime.genericCast <T>(buf[j]); buf[j--] = t; } } if ((lo < j)) { this.quicksort(lo, j, f); } if ((i < hi)) { this.quicksort(i, hi, f); } } }
public static T sort <T>(T list, global::haxe.lang.Function cmp) { unchecked { #line 44 "/opt/haxe/std/haxe/ds/ListSort.hx" if (global::haxe.lang.Runtime.eq(list, default(T))) { #line 45 "/opt/haxe/std/haxe/ds/ListSort.hx" return(default(T)); } #line 46 "/opt/haxe/std/haxe/ds/ListSort.hx" int insize = 1; #line 46 "/opt/haxe/std/haxe/ds/ListSort.hx" int nmerges = default(int); #line 46 "/opt/haxe/std/haxe/ds/ListSort.hx" int psize = 0; #line 46 "/opt/haxe/std/haxe/ds/ListSort.hx" int qsize = 0; T p = default(T); T q = default(T); T e = default(T); T tail = default(T); #line 48 "/opt/haxe/std/haxe/ds/ListSort.hx" while (true) { #line 49 "/opt/haxe/std/haxe/ds/ListSort.hx" p = list; list = default(T); #line 51 "/opt/haxe/std/haxe/ds/ListSort.hx" tail = default(T); nmerges = 0; #line 53 "/opt/haxe/std/haxe/ds/ListSort.hx" while ((!(global::haxe.lang.Runtime.eq(p, default(T))))) { #line 54 "/opt/haxe/std/haxe/ds/ListSort.hx" ++nmerges; q = p; #line 56 "/opt/haxe/std/haxe/ds/ListSort.hx" psize = 0; { #line 57 "/opt/haxe/std/haxe/ds/ListSort.hx" int _g = 0; #line 57 "/opt/haxe/std/haxe/ds/ListSort.hx" int _g1 = insize; #line 57 "/opt/haxe/std/haxe/ds/ListSort.hx" while ((_g < _g1)) { #line 57 "/opt/haxe/std/haxe/ds/ListSort.hx" int i = _g++; ++psize; #line 59 "/opt/haxe/std/haxe/ds/ListSort.hx" q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); if (global::haxe.lang.Runtime.eq(q, default(T))) { #line 61 "/opt/haxe/std/haxe/ds/ListSort.hx" break; } } } #line 63 "/opt/haxe/std/haxe/ds/ListSort.hx" qsize = insize; while (((psize > 0) || ((qsize > 0) && (!(global::haxe.lang.Runtime.eq(q, default(T))))))) { #line 65 "/opt/haxe/std/haxe/ds/ListSort.hx" if ((psize == 0)) { #line 66 "/opt/haxe/std/haxe/ds/ListSort.hx" e = q; q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); #line 68 "/opt/haxe/std/haxe/ds/ListSort.hx" --qsize; } else if ((((qsize == 0) || global::haxe.lang.Runtime.eq(q, default(T))) || (((int)(cmp.__hx_invoke2_f(default(double), p, default(double), q))) <= 0))) { #line 70 "/opt/haxe/std/haxe/ds/ListSort.hx" e = p; p = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(p, "next", 1224901875, true)); #line 72 "/opt/haxe/std/haxe/ds/ListSort.hx" --psize; } else { #line 74 "/opt/haxe/std/haxe/ds/ListSort.hx" e = q; q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); #line 76 "/opt/haxe/std/haxe/ds/ListSort.hx" --qsize; } #line 78 "/opt/haxe/std/haxe/ds/ListSort.hx" if ((!(global::haxe.lang.Runtime.eq(tail, default(T))))) { #line 79 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr1 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(tail, "next", 1224901875, e)); } else { #line 81 "/opt/haxe/std/haxe/ds/ListSort.hx" list = e; } #line 82 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr2 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(e, "prev", 1247723251, tail)); tail = e; } #line 85 "/opt/haxe/std/haxe/ds/ListSort.hx" p = q; } #line 87 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr3 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(tail, "next", 1224901875, default(T))); if ((nmerges <= 1)) { #line 89 "/opt/haxe/std/haxe/ds/ListSort.hx" break; } #line 90 "/opt/haxe/std/haxe/ds/ListSort.hx" insize *= 2; } #line 92 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr4 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(list, "prev", 1247723251, tail)); return(list); } #line default }
public static T sortSingleLinked <T>(T list, global::haxe.lang.Function cmp) { unchecked { #line 100 "/opt/haxe/std/haxe/ds/ListSort.hx" if (global::haxe.lang.Runtime.eq(list, default(T))) { #line 101 "/opt/haxe/std/haxe/ds/ListSort.hx" return(default(T)); } #line 102 "/opt/haxe/std/haxe/ds/ListSort.hx" int insize = 1; #line 102 "/opt/haxe/std/haxe/ds/ListSort.hx" int nmerges = default(int); #line 102 "/opt/haxe/std/haxe/ds/ListSort.hx" int psize = 0; #line 102 "/opt/haxe/std/haxe/ds/ListSort.hx" int qsize = 0; T p = default(T); T q = default(T); T e = default(T); T tail = default(T); #line 104 "/opt/haxe/std/haxe/ds/ListSort.hx" while (true) { #line 105 "/opt/haxe/std/haxe/ds/ListSort.hx" p = list; list = default(T); #line 107 "/opt/haxe/std/haxe/ds/ListSort.hx" tail = default(T); nmerges = 0; #line 109 "/opt/haxe/std/haxe/ds/ListSort.hx" while ((!(global::haxe.lang.Runtime.eq(p, default(T))))) { #line 110 "/opt/haxe/std/haxe/ds/ListSort.hx" ++nmerges; q = p; #line 112 "/opt/haxe/std/haxe/ds/ListSort.hx" psize = 0; { #line 113 "/opt/haxe/std/haxe/ds/ListSort.hx" int _g = 0; #line 113 "/opt/haxe/std/haxe/ds/ListSort.hx" int _g1 = insize; #line 113 "/opt/haxe/std/haxe/ds/ListSort.hx" while ((_g < _g1)) { #line 113 "/opt/haxe/std/haxe/ds/ListSort.hx" int i = _g++; ++psize; #line 115 "/opt/haxe/std/haxe/ds/ListSort.hx" q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); if (global::haxe.lang.Runtime.eq(q, default(T))) { #line 117 "/opt/haxe/std/haxe/ds/ListSort.hx" break; } } } #line 119 "/opt/haxe/std/haxe/ds/ListSort.hx" qsize = insize; while (((psize > 0) || ((qsize > 0) && (!(global::haxe.lang.Runtime.eq(q, default(T))))))) { #line 121 "/opt/haxe/std/haxe/ds/ListSort.hx" if ((psize == 0)) { #line 122 "/opt/haxe/std/haxe/ds/ListSort.hx" e = q; q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); #line 124 "/opt/haxe/std/haxe/ds/ListSort.hx" --qsize; } else if ((((qsize == 0) || global::haxe.lang.Runtime.eq(q, default(T))) || (((int)(cmp.__hx_invoke2_f(default(double), p, default(double), q))) <= 0))) { #line 126 "/opt/haxe/std/haxe/ds/ListSort.hx" e = p; p = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(p, "next", 1224901875, true)); #line 128 "/opt/haxe/std/haxe/ds/ListSort.hx" --psize; } else { #line 130 "/opt/haxe/std/haxe/ds/ListSort.hx" e = q; q = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.getField(q, "next", 1224901875, true)); #line 132 "/opt/haxe/std/haxe/ds/ListSort.hx" --qsize; } #line 134 "/opt/haxe/std/haxe/ds/ListSort.hx" if ((!(global::haxe.lang.Runtime.eq(tail, default(T))))) { #line 135 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr1 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(tail, "next", 1224901875, e)); } else { #line 137 "/opt/haxe/std/haxe/ds/ListSort.hx" list = e; } #line 138 "/opt/haxe/std/haxe/ds/ListSort.hx" tail = e; } #line 140 "/opt/haxe/std/haxe/ds/ListSort.hx" p = q; } #line 142 "/opt/haxe/std/haxe/ds/ListSort.hx" T __temp_expr2 = global::haxe.lang.Runtime.genericCast <T>(global::haxe.lang.Runtime.setField(tail, "next", 1224901875, default(T))); if ((nmerges <= 1)) { #line 144 "/opt/haxe/std/haxe/ds/ListSort.hx" break; } #line 145 "/opt/haxe/std/haxe/ds/ListSort.hx" insize *= 2; } #line 147 "/opt/haxe/std/haxe/ds/ListSort.hx" return(list); } #line default }
public static void doMerge <T>(global::Array <T> a, global::haxe.lang.Function cmp, int @from, int pivot, int to, int len1, int len2) { unchecked { #line 69 "/opt/haxe/std/haxe/ds/ArraySort.hx" int first_cut = default(int); #line 69 "/opt/haxe/std/haxe/ds/ArraySort.hx" int second_cut = default(int); #line 69 "/opt/haxe/std/haxe/ds/ArraySort.hx" int len11 = default(int); #line 69 "/opt/haxe/std/haxe/ds/ArraySort.hx" int len22 = default(int); if (((len1 == 0) || (len2 == 0))) { #line 71 "/opt/haxe/std/haxe/ds/ArraySort.hx" return; } #line 72 "/opt/haxe/std/haxe/ds/ArraySort.hx" if (((len1 + len2) == 2)) { #line 73 "/opt/haxe/std/haxe/ds/ArraySort.hx" if ((((int)(cmp.__hx_invoke2_f(default(double), a[pivot], default(double), a[@from]))) < 0)) { #line 74 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.swap <T>(((global::Array <T>)(a)), ((int)(pivot)), ((int)(@from))); } #line 75 "/opt/haxe/std/haxe/ds/ArraySort.hx" return; } #line 77 "/opt/haxe/std/haxe/ds/ArraySort.hx" if ((len1 > len2)) { #line 78 "/opt/haxe/std/haxe/ds/ArraySort.hx" len11 = (len1 >> 1); first_cut = (@from + len11); #line 80 "/opt/haxe/std/haxe/ds/ArraySort.hx" second_cut = global::haxe.ds.ArraySort.lower <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(pivot)), ((int)(to)), ((int)(first_cut))); len22 = (second_cut - pivot); } else { #line 83 "/opt/haxe/std/haxe/ds/ArraySort.hx" len22 = (len2 >> 1); second_cut = (pivot + len22); #line 85 "/opt/haxe/std/haxe/ds/ArraySort.hx" first_cut = global::haxe.ds.ArraySort.upper <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(@from)), ((int)(pivot)), ((int)(second_cut))); len11 = (first_cut - @from); } #line 88 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.rotate <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(first_cut)), ((int)(pivot)), ((int)(second_cut))); #line 69 "/opt/haxe/std/haxe/ds/ArraySort.hx" int new_mid = (first_cut + len22); #line 90 "/opt/haxe/std/haxe/ds/ArraySort.hx" global::haxe.ds.ArraySort.doMerge <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(@from)), ((int)(first_cut)), ((int)(new_mid)), ((int)(len11)), ((int)(len22))); global::haxe.ds.ArraySort.doMerge <T>(((global::Array <T>)(a)), ((global::haxe.lang.Function)(cmp)), ((int)(new_mid)), ((int)(second_cut)), ((int)(to)), ((int)((len1 - len11))), ((int)((len2 - len22)))); } #line default }
public static int compare <T>(global::Array <T> a, global::haxe.lang.Function cmp, int i, int j) { #line 160 "/opt/haxe/std/haxe/ds/ArraySort.hx" return((int)(cmp.__hx_invoke2_f(default(double), a[i], default(double), a[j]))); }