quicksort was buggy lol
This commit is contained in:
parent
4c0e79e173
commit
4e24903b18
17
thiersort.h
17
thiersort.h
@ -477,9 +477,16 @@ static inline void ts_quicksort_inplace(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Fix left to be after the point of separation in odd lengths */
|
||||||
|
if(left == right) {
|
||||||
|
tskey leftkey = arr[left].key;
|
||||||
|
TSU32 lefti = arr[left].i;
|
||||||
|
left += (lt(pivotkey, leftkey, pivoti, lefti, reent_data));
|
||||||
|
}
|
||||||
|
|
||||||
/* Just simple recursion for now */
|
/* Just simple recursion for now */
|
||||||
ts_quicksort_inplace(arr, from, mid, lt, reent_data);
|
ts_quicksort_inplace(arr, from, left, lt, reent_data);
|
||||||
ts_quicksort_inplace(arr, mid, to, lt, reent_data);
|
ts_quicksort_inplace(arr, left, to, lt, reent_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -516,9 +523,9 @@ static inline void ts_quicksort_fromto(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Just simple recursion for now */
|
/* Can use inplace steps from now on */
|
||||||
ts_quicksort_inplace(dst, from, mid, lt, reent_data);
|
ts_quicksort_inplace(dst, from, li, lt, reent_data);
|
||||||
ts_quicksort_inplace(dst, mid, to, lt, reent_data);
|
ts_quicksort_inplace(dst, li, to, lt, reent_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal code reuse (type-branches should be optimized out) */
|
/** Internal code reuse (type-branches should be optimized out) */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user