temporarily do naive array separate code for debugging

This commit is contained in:
Richard Thier 2022-08-16 12:16:31 +02:00
parent fbea1e607c
commit 6073c03f81

View File

@ -20,6 +20,9 @@
#include <stdint.h>
#include <assert.h>
// FIXME: vector is for debugging
#include <vector>
/**
* 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<uint32_t> 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;
}