diff --git a/space_partitioning_sort/spsort.h b/space_partitioning_sort/spsort.h index 31804e0..296fbba 100644 --- a/space_partitioning_sort/spsort.h +++ b/space_partitioning_sort/spsort.h @@ -20,6 +20,9 @@ #include #include +// FIXME: vector is for debugging +#include + /** * A binary search based function * to find the position @@ -78,6 +81,7 @@ struct lr { }; inline struct lr internal_array_separate(uint32_t *t, int n, uint32_t low, uint32_t mid, uint32_t high) { + /* // Init left-right "write head" indices int left = 0; int right = n - 1; @@ -105,6 +109,31 @@ inline struct lr internal_array_separate(uint32_t *t, int n, uint32_t low, uint3 eler.left = left; eler.right = right; + return eler; + */ + + // FIXME: bad quality debug code to remove + std::vector v(n); + int left = 0; + int right = n - 1; + auto current = t[0]; + for(int i = 0; i < n; ++i) { + if(current < mid) { + v[left++] = current; + current = t[i + 1]; + } else { + v[right--] = current; + current = t[i + 1]; + } + } + for(int i = 0; i < n; ++i) { + t[i] = v[i]; + } + + struct lr eler; + eler.left = left; + eler.right = right; + return eler; }